Reputation: 369
I am implementing a WPF application and I want to use UI libraries, I found "ModernWpfUI" and "HandyControl" in visual studio NuGet and I have installed them. Now I want to use them in one WPF window separately. For example I want to have two Slider in a window which the first one has "ModernWpfUI" style and the second has "HandyControl" style.
for this I added
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:ThemeResources />
<ui:XamlControlsResources />
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
to my .xaml file and then I added
<Slider Orientation="Vertical" Margin="309,48,444,98" ></Slider>
<Slider Orientation="Vertical" Margin="413,48,340,98"></Slider>
but now both of them have same style ("HandyControl" style). how can I have
<Slider Orientation="Vertical" Margin="309,48,444,98" ></Slider>
<!---- With HandyControl style-->
<Slider Orientation="Vertical" Margin="413,48,340,98"></Slider>
<!---- With ModernWpfUI style-->
Upvotes: 1
Views: 280
Reputation: 169150
Set the Style
property of each control explicitly to the Style
you want to apply. This should work:
<!---- With HandyControl style-->
<Slider Style="{StaticResource SliderBaseStyle}" Orientation="Vertical" Margin="309,48,444,98" />
<!---- With ModernWpfUI style-->
<Slider Style="{StaticResource DefaultSliderStyle}" Orientation="Vertical" Margin="413,48,340,98"/>
Upvotes: 1
Reputation: 2509
The reason why this is happening is that both ModernWpfUI and HandyControl are using implicit styles for the Slider
control.
That is, their styles are applied to the type vs. a style key. So the last one defined in your resources wins. In this case HandyControl.
To use both styles, you'll need to use an explicit style key for each one. You can get the style key by looking at their XAML.
It would look something like this:
<Slider Orientation="Vertical" Margin="309,48,444,98" Style="{DynamicResource WhatEverHandlyControlStyleIs}" />
<!---- With HandyControl style-->
<Slider Orientation="Vertical" Margin="413,48,340,98" Style="{DynamicResource DefaultSliderStyle}" />
<!---- With ModernWpfUI style-->
Upvotes: 1