Is it possible to inherit same style for a ControlTemplate in two different windows? I'm new to wpf and I'm not sure how to do it or even if it's possible. For example if I have in Window1.xaml:
<Window.Resources>
<ControlTemplate x:Key="myStyle" TargetType="Button">
...
</ControlTemplate>
</Window.Resources>
And in Window2.xaml I want to use it like this:
<Grid>
<Grid.Resources>
<Style TargetType="Button" BasedOn="{StaticResource myStyle}">
...
</Style>
</Grid.Resources>
<Grid>
How do I import the style from the first window?
Yes it is possible, you can move style to app.xaml, and both windows will see that style
something like this in app.xaml
<Application.Resources>
<ResourceDictionary>
<Style x:Key="myStyle" TargetType="Button">
...
</Style>
<Style TargetType="Button" BasedOn="{StaticResource myStyle}">
...
</Style>
</ResourceDictionary>
</Application.Resources>
and both windows will see that style
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With