tags:

views:

250

answers:

1

Hi, I have a custom control which is dynamically adding a number of checkboxes. I can't figure out how to apply a default style to them from code in the custom control (from the generic.xaml file)

+2  A: 

Hi,

I am having a shot in the dark here, but do you have a default "theme" file that you want to apply to dynamically added UIelements in some custom UserControl?

if so,

Try something like:

public Page()
        {
            InitializeComponent();
            Uri uri = new Uri(@"QuoteInterface;component/Theme/WhistlerBlue.xaml", UriKind.Relative);
            ImplicitStyleManager.SetResourceDictionaryUri(LayoutRoot, uri);
            ImplicitStyleManager.SetApplyMode(LayoutRoot, ImplicitStylesApplyMode.Auto);
            ImplicitStyleManager.Apply(LayoutRoot);
        }

That seems to work for me, even when I add dynamically generated user controls

Johannes
I've not had a play with the StyleManager stuff, that's in the toolkit right? I'll check it out and see if it does what I need. Thanks
Stephen Price
James Cadd