Wednesday, January 16, 2013

SetResourceReference is the Awesome-Sauce for Styling

One of the biggest issues I've had with developing custom views is that there are so many different ways to implement your styling and linkage.  The best way I've found is just to call the following in the constructor:

SetResourceReference(StyleProperty, typeof(MyControl));

Wherein MyControl is the control you're working with.

A lot of people work with the default style key -- but I've found that in larger projects, there can sometimes be issues with this.  Using SetResourceReference has worked for me every single time.

Food for thought!

Monday, January 7, 2013

The type or namespace cannot be found... C# and the Client Profile woes

So, this is a very funny and unusual error I bumped into today -- and it drove me mad for a few hours.

When I build components, I generally like to abstract them out into a little test-bed WPF application.  Every time I kept compiling, it would blow up on a simple, new component I had just added, with a message looking like...

"The type or namespace '{0}' cannot be found."

When I did try to resolve it -- it pointed out a flaw in our architecture, wherein some numb-skull decided to rename a namespace in one assembly to that of another.  After I fixed that, I found that it was STILL not the problem.

Then I looked again -- for whatever I could find -- in my test-bed's properties.

It was set to run in .NET 4.0 Client Profile.  When I changed it back to .NET 4.0, everything compiled and worked fine.

In the future, I need to double check these things -- hopefully someone else will read this post and later figure this out as well!