February 28th, 2007
So tonight I was plugging away on Times Reader and I tried to use the MyControl.Template.FindName() method. When I didn’t get what I wanted I hit up MSDN. It gave me the following.
MSDN Recommendation
I thought to myself, “Oh yah…I haven’t used GetTemplateChild or seen it used in over a year! I wonder what the difference between GetTemplateChild() and Template.FindName() is?” Taking advantage of Visual Studio’s “Hover Over Method Name and Get a Description” feature, I recieved the following when I moused over the GetTemplateChild method.
Method “ToolTip” Recommendation
I didn’t know who to believe. On the one hand, MSDN is the DEVELOPERS NETWORK! But on the other hand, I know the tooltip comes straight from the developer of GetTemplateChild.
In end I didn’t use either. I figured MSDN probably hadn’t updated that doc yet and who’s going to take advice from a tooltip anyways. Seriously…the way they just pop in when you mouse over something reminds me to much of how my skeezy neighbor just “pops in” whenever I’m near my apartment door.
Instead I just used the WPF.StopConfusingMe() method. Now all my controls display “NO”.
Posted in Main, WPF | No Comments »
February 25th, 2007

So what started out as an experiment with point animations has turned into something I’m sure will quickly become my great contribution to the world. (Please save your applause for the end of this post.) What am I talking about? Wobbly Controls Baby. Controls…that…WOBBLE. (Seriously, please contain your ooohs and aaaahs or we’ll never get through this post.) Now I know what you’re thinking. “Where can I get these wonderful controls? How can I integrate them into my business’s application?” Well, I’m giving them to you here and now…free of charge. That’s right…FREE. Because that’s the kind of guy I am. You can find links to source and binaries at the bottom of this post.
No…seriously…what’s the point of Wobbly Controls?
Ok, I’m not fooling anyone. These controls are beyond pointless. They might even be considered annoying. Like I mentioned above, this was just an experiment with point animations where I made a box wobble. But then I started playing with Expression Blend and had it pump out template’s for your basic WPF controls. Inserting my WobbleBox as a ContentPresenter into each of these control’s templates was a snap…and then, BAM…Wobble Controls.
So why the blog post? This turned out to be a fairly good exercise that I think anyone who wants to break into the world of WPF via Expression Blend or Hand Edited Xaml could benefit from.
What did I learn and/or relearn from this?
-
I really need to take Expression Blend more serious as a WPF tool.
- They’ve made some great advances with Expression Blend over the past few months. I’m still not to the point where I’ll do most of my xaml work in it but I find it tremendously useful for “tweaking”. Plus, for this exercise, having Blend create all of the default templates for me was super easy. It was interesting to read through the xaml and see how a lot of these controls were put together. Very educational. (Look at ComboBox for a good example.)
-
Controls are a lot more complicated then they appear.
- Sometimes it’s easy to look at a control like ComboBox and think…ooo…wow…a button with a popup…I can totally build that. But when you really get down to it there’s tons of things going on you don’t realize. There’s template’s for an Editable ComboBox, an Uneditable ComboBox, it’s ArrowButtons, the Popup…etc etc. Then there are the states you have to handle: MouseOver, HasFocus, Doesn’t Have Focus, MousePresseDown…etc etc. And don’t forget your bindings. Should you use a TemplateBinding? What property should you bind to…Background…BorderBrush…Forground…a System Value? And lastly, if your going to build a decent reusable control it needs to be extendable. I should point out that I did not do most of this work for my Wobbly Controls. I did some minor work, enough to make things presentable, and what Blend didn’t handle I just ignored. Mainly, because I don’t ever expect to see a Wobbly Control in real world use.
- Building Controls Is Fun
- Whether I’m building a completely custom control or extending controls that already exists (like Wobbly Controls) I always learn something new. I’ve been working with WPF for two straight years and I’m still finding better ways of doing things. Sometimes I get frustrated that the same task can be done in WPF twelve different ways, but I always get excited when I find that thirteenth better way. (NOTE: Do not download the source for Wobbly Controls and assume I did everything 100% properly. The way I created the controls and laid out the example was more for demonstrative purposes than following my own coding guidelines. For example: Each control has all of its non-shared resources in it’s own personal resource dictionary. This is bad mojo. I normally would create a resource dictionary to hold all of these styles and templates. In fact, I wouldn’t even have created a custom Class for each control because I don’t extend any of the functionality. Making a style and applying it to a normal button would have been way better.)
- Debugging Xaml In Visual Studio Is a Pain
-
This goes double if your xaml exists in a library that your application references. Unless you enjoy drilling down an exception tree from Inner Exception to Inner Exception I encourage you to do most of your xaml work in Blend or XamlPad. Or at the least, build your controls in the application assembly and then move them over to the library. There’s nothing worse then having to spend a ton of time digging through the annoying runtime error dialog only to find you typed “VerticalAlignment=Left”.
- Wobbly Popups Are a Bad Idea
- I knew Popups don’t get any love from the Video Card’s GPU but I just had to try it. After finally being able to wrench back control of my CPU I decided that not everything needs to be wobbly. Case In Point
Wow…this post has gone on longer than planned…and it’s getting kind of preachy. I’ll end by saying that doing pointless things like WobblyControls can be very educational. WPF is HUGE and there’s always another “tip” or “trick” you haven’t discovered that can help out the next time your doing real work.
Play With Wobbly Controls
Posted in Main, WPF | 5 Comments »
February 22nd, 2007
You might have noticed my subtle blog post on Josh Smith’s Xbap Competition. Apparently, there are still some servers out there who haven’t registered xbap mime types so not every can submit an application. This has caused Josh to reconsider and ultimately open the competition up to ALL WPF APPS! So now you don’t have an excuse not to submit an entry. Get on with it already!
Posted in Main, WPF | No Comments »
February 17th, 2007
So I was digging through a bunch of test projects I had created a while ago and I stumbled across a project involving embedded fonts. I was about to delete the project when I saw that I had my app referencing fonts embedded in a library. This got me thinking about building applications where all of your visual information (colors, images, etc etc) could live in a library outside of your application. Then multiple apps could share the same visual resources or you could even set up your app to read in these library’s like skins.
Not that unique of an idea but with WPF’s Resource Dictionaries and Embedded Fonts this would be a very simple thing to do with some super hip rewards. Example: Let’s say after a year since you released your app you feel it could stand a visual redesign. Just throw together a new library, update the user’s “graphicslibrary.dll” and wham…you’re done. Or just push to the user as a new “skin file”. It’s almost to easy.
Now that I’ve decided every WPF app built from this day forward should have something like I just described, I’d better make a post so you know how to embed fonts.
Embedding and Referencing Fonts in your application and/or library is very simple.
First you’ll need to add your fonts to your project. In the image below you can see where I added the NEUROPOL.ttf font to my application and the VINQUE.ttf font to my library. NOTE: In your properties for the fonts make sure that “Build Action” is set to “Resource”. I believe that is the default value.

Now it’s just a matter of referencing the fonts in your xaml. (Normally I would make a reference to the FontFamily in a ResourceDictionary but for the sake of this example I just slapped it on the TextBoxes.)

The reference to the application’s embedded font on the first TextBox is fairly straight forward. It follows the format: /[PathToResource]/#[FontFamilyName]
The second reference to the library’s embedded font is a little trickier. It’s format is: /[LibraryAssemblyName];Component/[PathToResource]/#[FontFamilyName]
Oh…and don’t forget to add your library to your application’s References.
When it’s all said and done you get the following.

Yes I took screenshots of Visual Studio. It’s easier then hacking XAML into WordPress and I think it looks better. Since you can’t copy & paste here’s the SOURCE CODE.
Now get out there and start making skins for your apps. I’m going to spend the next couple of hours making a Star Wars Theme for Times Reader. Hmmm…or maybe a Mid-Evil Dragon Themed Times Reader. With Elfs…and Dwarfs…and Maidens…YAH…lots of Maidens…with swords…
Posted in Main, WPF | 4 Comments »
February 15th, 2007
MONDAY MONDAY MONDAAAAAAYYY!

Are you man enough?
Are you woman enough?
You think you can write a mean lick of code?
Are you looking to prove yourself in the mighty WPF Arena?
Then get your ass over to Josh Smiths for a style crashin‘, template bashin‘, xaml thrashin‘, XBap Battlefest Extravaganza!!!
On March 12 Josh Smith is giving you the chance to test your WPF Metal against other code crunchers who eat noobs like you for breakfast!
MONDAY MONDAY MONDAAAAAAYYY!
Don’t miss out on this once-in-a-lifetime bone chilling event. There’s prizes for the champ with right kind of grit! So stop trembling in the corner and show em what you’ve got.
MONDAY! MONDAY! MONDAAAAAAY!!!!
Be there or be embarrassed! You can pay for the whole ticket, but we guarentee you’ll only need the edge of your seat!
MONDAY! MAYHEM! MONDAAAAAAYYY!!!!
Josh Smith’s Heart Pounding Best XBap Challenge of DOOOOOOOM!!!!
Posted in Main, WPF | 1 Comment »
February 15th, 2007
So Josh Smith has recently been hired by the “Old Grey Lady” to work on Times Reader with me. His ridiculous enthusiasm for WPF has sparked my own ridiculous enthusiasm and now I’m feeling to urge to not only read more WPF blogs and articles but to take a crack at sharing my own little tidbits of WPF wisdom again.
But I needed a better look. So I spent a couple nights trying to remember how to use photoshop, php and css. And let me tell you what…if this site doesn’t scream professionalism…well…I don’t want to know what does.
Instead of a having a bunch of sub-domains I’ve divided this one blog into 3 topics.
WPF - Where I’ll blog on WPF and other boring code related things.
Friends & Family - This will allow me to post pictures and information for people who’d rather not talk to me on the phone but can’t handle the guilt associated with avoiding me.
Rants - This is because whenever I get a good rant going nobody will listen. Well…now you don’t have a choice. (As long as I believe it…it’s true.)
But I have to be honest. I won’t blog much and when I do my grammer will make you shudder and my spelling will make you cringe. It’s a gift…I know.
You can still find my old blogs at the following links. I might even bring some of the content over to this one.
http://wpf.nickthuesen.com (Old WPF Blog)
http://newyork.nickthuesen.com (Old Friends & Fams)
Posted in Friends & Fam, Main, Rants, WPF | No Comments »