Resource Dictionary
Hi Guys,
Sorry for the newbie question, but this is my first time using Resource Dictionaries with Noesis. I've read the documentation, but I'm not connecting the dots.
I've created a merged dictionary and put a few button styles in it. The buttons look fine in WPF, but default to the Noesis Style in XAML Player.
The merged dictionary is being set in app.xaml:
And then I have my resource dictionary, ResourceDictionaryButtonStyles.xaml. These files are in the same directory as my other XAML files.
Ultimately, I'll have a few more resource dictionaries for button styles, colors and languages.
Again, sorry for the simple question and thanks!
Rob
Sorry for the newbie question, but this is my first time using Resource Dictionaries with Noesis. I've read the documentation, but I'm not connecting the dots.
I've created a merged dictionary and put a few button styles in it. The buttons look fine in WPF, but default to the Noesis Style in XAML Player.
The merged dictionary is being set in app.xaml:
Code: Select all
<Application.Resources>
<!-- Resources scoped at the Application level should be defined here. -->
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ResourceDictionaryButtonStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Ultimately, I'll have a few more resource dictionaries for button styles, colors and languages.
Again, sorry for the simple question and thanks!
Rob
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: Resource Dictionary
Hi Rob,
The App.xaml is not used when you integrate NoesisGUI in your application.
To use resource dictionaries in your application you have two options:
Hope this helps.
The App.xaml is not used when you integrate NoesisGUI in your application.
To use resource dictionaries in your application you have two options:
- Create a Theme dictionary that you can set globally to the application through IUISystem::SetTheme(). The styles and resources defined there will be used by all the xamls if no local resources are found. It is a good way to share resources and minimize memory consumption.
- Or add the dictionary in the MergedDictionaries of any xaml you want to use it.
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ResourceDictionaryButtonStyles.xaml">
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Grid.Resources>
<!-- your UI design here -->
</Grid>
Re: Resource Dictionary
"Or add the dictionary in the MergedDictionaries of any xaml you want to use it."
Where does this go in the XAML? Can I assign it somewhere in resources for the entire XAML or do I need to assign it per element/object?
Thanks again. I really appreciate you guys being so responsive!!
Where does this go in the XAML? Can I assign it somewhere in resources for the entire XAML or do I need to assign it per element/object?
Thanks again. I really appreciate you guys being so responsive!!
Re: Resource Dictionary
Ok, figured this out.
Moved the </ResourceDictionary> tag to end of all styles and above </UserControl.Resources>. Seems to be happy again.
Moved the </ResourceDictionary> tag to end of all styles and above </UserControl.Resources>. Seems to be happy again.
Re: Resource Dictionary
That is. The ResourceDictionary is normally included in the Resources property of the root element. That way it is available to all the elements of the XAML.
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests