jrandomuser
jrandomuser

Reputation: 1720

WPF Windows within Windows Forms as MDI where do I put the contents of App.xaml?

Due to circumstances beyond my control I must host some WPF screens inside a Windows Form app as an MDI child. I belive I know how to do this and have moved almost everything over. However I am not sure what to do with the Styles set in my App.xaml file.

How / where do I set a Global Styles reference?

Upvotes: 0

Views: 520

Answers (1)

user1859022
user1859022

Reputation: 2695

since the App.xaml file is ignored in a WinForms app you will have to use a RecourceDictionary in watherver your UI root control is:

<Page.Resources>
  <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="myresourcedictionary.xaml"/>
    </ResourceDictionary.MergedDictionaries>
  </ResourceDictionary>
</Page.Resources>

to include local resources you would frist create a ResourceDictionaryfor your local resources and then add the MergedDictionarieslike so:

<Page.Resources>
  <ResourceDictionary>
    <!--local resources-->
    <Style x:Key="My Style">
    ...
    </Style>

    <!--"global" resources from file-->
    <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="myresourcedictionary.xaml"/>
    </ResourceDictionary.MergedDictionaries>
  </ResourceDictionary>
</Page.Resources>

Upvotes: 1

Related Questions