I think you can implement this action through the attached DependencyProperty . Something like this (this is a simple work example):
XAML
<Window x:Class="ShutdownAppHelp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:ShutdownAppHelp" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <Style TargetType="{x:Type CheckBox}"> <Style.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter Property="local:ProgramBehaviours.Shutdown" Value="True" /> </Trigger> </Style.Triggers> </Style> </Window.Resources> <Grid> <CheckBox Content=" Shutdown" IsChecked="False" /> </Grid> </Window>
Code behind
namespace ShutdownAppHelp { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } } public static class ProgramBehaviours {
You can put any behavior into DependencyProperty , which is accessible only through code and call it XAML:
<DataTrigger Binding="{Binding ElementName=SomeControl, Path=Tag}" Value="Shutdown"> <Setter Property="local:ProgramBehaviours.Shutdown" Value="True" /> </DataTrigger>
In addition, you can access it directly through the behavior code:
ProgramBehaviours.SetShutdown(SomeControl, Value);
Or from XAML without a condition:
<SomeControl local:ProgramBehaviours.SetShutdown="True" ... />
source share