programming-examples/c-sharp/Others/Style With Data Trigger.cs
2019-11-15 12:59:38 +01:00

29 lines
988 B
C#

Style With Data Trigger
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="FontSize" Value="24" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Margin" Value="24" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=txtbox,
Path=Text.Length}"
Value="0">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Resources>
<TextBox Name="txtbox" HorizontalAlignment="Center"
Width="2in" Margin="24" />
<Button>
Button Number 1
</Button>
</StackPanel>