Page 1 of 1

Resource Dictionary

Posted: 04 Dec 2014, 19:28
by walhore
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:
<Application.Resources>
	<!-- Resources scoped at the Application level should be defined here. -->
	<ResourceDictionary>
		<ResourceDictionary.MergedDictionaries>
			<ResourceDictionary Source="ResourceDictionaryButtonStyles.xaml"/>
		</ResourceDictionary.MergedDictionaries>
	</ResourceDictionary>
</Application.Resources>
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

Re: Resource Dictionary

Posted: 05 Dec 2014, 16:59
by sfernandez
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:
  • 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.
Inside XamlPlayer only the second option will be valid, because Theme dictionary is set by XamlPlayer application. So only resources defined in the xaml (directly or via MergedDictionaries) you are loading can be found. If you want to try the styles you defined in the ResourceDictionaryButtonStyles.xaml in XamlPlayer, you have to include it in the xaml you are working with:
<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>
Hope this helps.

Re: Resource Dictionary

Posted: 09 Dec 2014, 17:37
by walhore
"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!!

Re: Resource Dictionary

Posted: 09 Dec 2014, 21:29
by walhore
Ok, figured this out.

Moved the </ResourceDictionary> tag to end of all styles and above </UserControl.Resources>. Seems to be happy again.

Re: Resource Dictionary

Posted: 10 Dec 2014, 00:57
by jsantos
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.