I'm relatively new to WPF. I have two dictionaries with style definitions which I later use in XAML views.
The base style (in CommonStyles.xaml
):
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:MyProject.Theme">
<...>
<Style x:Key="RoundCornerButton" TargetType="{x:Type Button}">
<...>
</Style>
</ResourceDictionary>
The specific style (what I've have tried) (in SpecificStyles.xaml
):
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:MyProject.Theme">
<...>
<Style x:Key="RoundCornerButtonWithCheck" TargetType="{x:Type Button}" BasedOn="{StaticResource RoundCornerButton}">
<...>
</style>
</ResourceDictionary>
What I want to do is to use the style RoundCornerButton
defined within CommonStyles.xaml
as the "parent" style of RoundCornerButtonWithCheck
in SpecificStyles.xaml
, I mean, as the value of BasedOn
property (kind of inheritance).
I've also tried setting the property BasedOn
this way:
BasedOn="{StaticResource {local:Style RoundCornerButton}}"
As CommonStyles.xaml
is inside the folder Theme/ inside MyProject/, I thought I could access it through local:
namespace in some way,
but I'm not sure how to do this.
I've been looking at the documentation of BasedOn
property as well as other resources, but I'm still confused.