Open sumit-codebrewer opened 9 months ago
Where did you put ThemeResource
and XamlControlResource
in?
They should be put in the App.Resources. Did you follow the Quick Start Guide?
I put that in app.xaml and it is applying the modern styles in every window. But talking about User control, it is not showing the same behaviour in this case.
Ideally, I want this kind of color in dark theme
What I am getting in case of user control being called in another window
Any ideas, how to fix this?
I was able to get this to work for UserControl by manually merging resources for UserControl, and then forcing the style on the buttons:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:ThemeResources />
<ui:XamlControlsResources />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Button
Content="{Binding ButtonContent}"
Style="{StaticResource DefaultButtonStyle}">
I was able to get this to work for UserControl by manually merging resources for UserControl, and then forcing the style on the buttons:
<UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ui:ThemeResources /> <ui:XamlControlsResources /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </UserControl.Resources>
<Button Content="{Binding ButtonContent}" Style="{StaticResource DefaultButtonStyle}">
I don't think this is a good idea. It will make the theme resources loaded twice. What about adding those to DesignTimeResources?
Any guides on how I can do this? Would really appreciate it - sorry I'm a little new to WPF development
OK removing the UserControl.Resources
and just manually specifying the style in the Button fixed the issue for me:
<Button
Content="{Binding ButtonContent}"
Style="{StaticResource DefaultButtonStyle}">
@biocross Maybe this solution is not bad.
However, in my scenario, everything works fine when adding themes into app.xaml.
I don't know why this doesn't work for you guys. I'm really confused.
The library looks good on my application, it has several styles that are making my windows look modern. Like, this how I implemented a settings page in my app.
The issue is, when I am trying to enable the same modern styles on the user control, it is showing different behaviour. Like this is how the buttons are looking here.
Kindly suggest a way to fix the same, so that the user control have the same properties as a normal window.