WPF Theming and dynamic controls

Posted by Eduard on Stack Overflow See other posts from Stack Overflow or by Eduard
Published on 2010-04-05T21:09:43Z Indexed on 2010/04/05 21:13 UTC
Read the original article Hit count: 522

Filed under:
|
|

Hello,

I am trying to add control to ContentPresenter on then run, but control I've added does not apply theme.

Theres is code with reference to theme in xaml file:

        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Resources/PocGraphDataTemplates.xaml" />
        </ResourceDictionary.MergedDictionaries>

Also I've tried to set style in code behind, does not work:

        this.graphLayout.Content = analyzerViewModel.AnalyzedLayout = new PocGraphLayout()
        {
            LayoutAlgorithmType = "FR"
        }; 
        ResourceDictionary rd = new ResourceDictionary();
        rd.Source = new Uri("Resources/PocGraphDataTemplates.xaml", UriKind.Relative);
        analyzerViewModel.AnalyzedLayout.Style = new Style(typeof(PocGraphLayout));
        analyzerViewModel.AnalyzedLayout.Style.Resources.MergedDictionaries.Add(rd);

When control was static everything worked fine:

<ViewModel:PocGraphLayout x:Name="graphLayout"
                                        Graph="{Binding Path=Graph}"
                                        LayoutAlgorithmType="{Binding Path=LayoutAlgorithmType}"
                                        Sample:LayoutManager.ManagedLayout="True"
                                        OverlapRemovalAlgorithmType="FSA"
                                        HighlightAlgorithmType="Simple" />

Any ideas?

PS. I am newbie in wpf.

© Stack Overflow or respective owner

Related posts about xaml

Related posts about wpf