i want to create a custom close button in window style that it relyes window’s close command.
i wrote something like this:
<Style x:Key="WindowsGeneralStyle" TargetType="Window">
...
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<Grid>
...
<Button x:Name="closebtn" Command={Binding Close} ... />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
but it didn’t work. How do this?
I resolved problem. I create a partial class for our ResourceDictionary and in the behind code i handled Close button click event:
ResourceDictionary XAML file:
and behind code:
Now,It works pretty well!