Friday, August 24, 2012

How to Change Application FontFamily at Runtime

This one stumped me for a while. There are a lot of blog posts out there on how to change the font family of a particular style if you know the key, or how to do it for all textblocks in the application. The problem I was facing was that I used a lot of Labels and other controls that did not pick up these changes. Not only that, but I found no way of editing my default styles at runtime. After trying several approaches, I came up with this solution. I don’t know if it will work for everyone, but in my case, it is working beautifully. I hope it helps.

        private void applyFontFamilySettings()
            foreach (DictionaryEntry entry in Application.Current.Resources)
                if (entry.Value is Style)
                    Style originalStyle = (Style)entry.Value;
                    swapStyles(originalStyle, entry.Key, originalStyle.TargetType);

        private void swapStyles(Style s, object styleKey, Type t)
            Style newStyle = new System.Windows.Style()
                TargetType = t

            foreach (Setter st in s.Setters)

            newStyle.Setters.Add(new Setter(FontFamilyProperty, UiSettings.FontFamily));
            Application.Current.Resources[styleKey] = newStyle;

Thursday, July 5, 2012

How to Create a Custom Stroke in Expression Design


1) First, draw whatever you want to be used as a stroke. In this case, I will drew an ant.


2) Select the paths with the selection tool and go to Object > Stroke > New Stroke Definition


This will open up a new tab that look something like this


3) Select everything with the selection tool and right click. You should see this:


This gives you the option to anchor the image and make repeating. In my case, I want the ants to repeat, so I select that.

4) File >  Save


Give your stroke an appropriate name.

That’s it. Now you should be able to use your stroke in your designs.


With this new stroke, I can now make a line of ants following whatever path I want.


I hope this helps! Have fun!

Thursday, February 2, 2012

Expression Blend Bug–Can’t Open UserControl

Ever seen this when trying to work in Blend?

(Element Name) is not supported in a windows presentation foundation (WPF) project.

or this?

(UserControl) is not supported in a windows presentation foundation (WPF) project.

Well, I ran into this and had a tough time figuring out what was going on. There are a lot of forum posts out there talking about the topic, but no real solution that I have found. I kept on trying different things and was able to overcome it. Here is what I did to fix it.

I went to the solution explorer in visual studio and right clicked on the project file for the project that was having the problems. I selected ‘Edit Project File’. This unloads the project from the current solution and opens the project file in the xml editor.

Towards the top of the file you should see something like this


After my offending project file with other functioning project files, I noticed that my platform was set to x86 rather than AnyCPU like my other projects. I changed it to AnyCPU, saved, reloaded the project, built the solution and then tried to open the UserControl in Blend. This fixed the problem!

If you are having this same issue, I’d give that a shot. Good luck!

Wednesday, January 18, 2012

How to be a Computer Expert!


This one is all over the web. Just thought I’d post it here in case you haven’t see it. It sums it up pretty well.

computer flow chart

Wednesday, January 11, 2012

How to Change the Font Size of a WPF Tab Control’s Header

To change the font size of the tab header of a wpf tab control you have to redefine the ItemTemplate property of the Tab Control.

This is a question I have heard a lot, so I decided to blog about it for those of you needing to do the same thing. Here is a code sample.

<DataTemplate x:Key=”temp”>

<TextBlock Text=”{Binding}” FontSize=”20”/>



<TabControl …. ItemTemplate=”{DynamicResource temp}”/>


That’s all there is to it.

Happy Coding!