User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.

28 Mar 2018, 15:42

Anyway, the resource dictionary structure you initially provided does fail in Blend.

When I run this example in Blend:

App.xaml
<Application x:Class="StaticResourceTest.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Buttons.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <SolidColorBrush x:Key="RedBrush" Color="Red"/>
        </ResourceDictionary>
    </Application.Resources>
</Application>
Buttons.xaml
<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ControlTemplate x:Key="ButtonTemplate" TargetType="Button">
        <Grid Background="{StaticResource RedBrush}"/>
    </ControlTemplate>
</ResourceDictionary>
MainWindow.xaml
<Window x:Class="StaticResourceTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Button Template="{StaticResource ButtonTemplate}"/>
    </Grid>
</Window>
It produces the following error:
Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception. Line number '5' and line position '10'
I cannot reference resources defined directly in the App.Resources from a merged dictionary set in App.Resources.
So I think you should avoid any hack and follow the guidelines I explained before.
 
Wanderer
Topic Author
Posts: 168
Joined: 08 May 2017, 18:36

Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.

28 Mar 2018, 16:52

Hmm.. I tried this:
Anyway, the resource dictionary structure you initially provided does fail in Blend.

When I run this example in Blend:

App.xaml
<Application x:Class="StaticResourceTest.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Buttons.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <SolidColorBrush x:Key="RedBrush" Color="Red"/>
        </ResourceDictionary>
    </Application.Resources>
</Application>
only with Noesis, not in Blend. I have in Blend this structure: (it is created automaticly, by Blend)
<Application x:Class="Zalohovaci_Program_GUI_2.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:Zalohovaci_Program_GUI_2"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="DarkFlatTheme.xaml"/>
                <ResourceDictionary Source="main_buttons_stat_stop.xaml"/>
                <ResourceDictionary Source="main_checkboxes_buttons.xaml"/>
                <ResourceDictionary Source="main_radiobuttons.xaml"/>
                <!-- And lot of others ResourceDictionary Source="xxx" -->
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
I cannot reference resources defined directly in the App.Resources from a merged dictionary set in App.Resources.
So I think you should avoid any hack and follow the guidelines I explained before.
Finally I did it and it working as I wish :) and without errors.

The code I was talking about should look like this:
// Noesis::GUI::Init() ...
// Noesis::GUI::SetXamlProvider/SetFontProvider/SetTextureProvider...

Ptr<Noesis::ResourceDictionary> appResources = *new ResourceDictionary();
Noesis::GUI::SetApplicationResources(appResources);

Ptr<Noesis::ResourceDictionary> commonResources =
    Noesis::GUI::LoadXaml<Noesis::ResourceDictionary>(
        "Themes/DarkFlat/DarkFlatTheme.xaml");
appResources->GetMergedDictionaries()->Add(commonResources);

Ptr<Noesis::ResourceDictionary> otherResources =
    Noesis::GUI::LoadXaml<Noesis::ResourceDictionary>(
        "Themes/DarkFlat/others.xaml");
appResources->GetMergedDictionaries()->Add(otherResources);
Thanks, it helped me. I read all xaml files from Theme directory and add it in to appResources. Now all missing mouseover graphics is displayed.
 
Wanderer
Topic Author
Posts: 168
Joined: 08 May 2017, 18:36

Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.

28 Mar 2018, 17:10

And one thing I must write. The DarkFlatTheme which contain all colors, must be loaded first, if not, then all xaml files which are loaded before DarkFlatTheme.xaml will have missing graphics for StaticResources.
 
User avatar
jsantos
Site Admin
Posts: 2905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.

29 Mar 2018, 15:22

The code I was talking about should look like this:
// Noesis::GUI::Init() ...
// Noesis::GUI::SetXamlProvider/SetFontProvider/SetTextureProvider...

Ptr<Noesis::ResourceDictionary> appResources = *new ResourceDictionary();
Noesis::GUI::SetApplicationResources(appResources);

Ptr<Noesis::ResourceDictionary> commonResources =
    Noesis::GUI::LoadXaml<Noesis::ResourceDictionary>(
        "Themes/DarkFlat/DarkFlatTheme.xaml");
appResources->GetMergedDictionaries()->Add(commonResources);

Ptr<Noesis::ResourceDictionary> otherResources =
    Noesis::GUI::LoadXaml<Noesis::ResourceDictionary>(
        "Themes/DarkFlat/others.xaml");
appResources->GetMergedDictionaries()->Add(otherResources);
Thanks, it helped me. I read all xaml files from Theme directory and add it in to appResources. Now all missing mouseover graphics is displayed.
Remember what Sergio said. You don't need that code at all. Just having everything as you have in Blend (but instead of inside App.xaml using SetApplicationResources) should work with Noesis. If it doesn't there is a bug.
 
Wanderer
Topic Author
Posts: 168
Joined: 08 May 2017, 18:36

Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.

29 Mar 2018, 15:41

Then there is bug. Because I tried it load one xaml file with mergedDictionaries first, and without succes (under console wrote it is loaded, but buttons under mouse show black colors). I add it in bugtracker and upload file.

Who is online

Users browsing this forum: Bing [Bot] and 1 guest