DataSwitch en - Leksiqq/WpfMarkupExtension GitHub Wiki
Attention! This article, as well as this announcement, are automatically translated from Russian.
Used in XAML markup similar to <DataTrigger>
. Has a Binding
attribute with the same meaning. The content consists of <DataTrigger>
elements without a Binding
attribute. Acts as if all <DataTrigger>
s have the same Binding
, but the binding value is only evaluated once.
in the demo on the "Demo3" tab, calls to the calculation of the binding value are displayed on the console in the case of using <DataSwitch>
and without it.
<TextBlock DockPanel.Dock="Top">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<l:DataSwitch Binding="{Binding Text, ElementName=T1,
Converter={l:ParameterizedResource DataConverter},
ConverterParameter=T1Text|DataSwitch, Mode=OneWay}">
<DataTrigger Value="1">
<Setter Property="Text" Value="Один"/>
</DataTrigger>
<DataTrigger Value="2">
<Setter Property="Text" Value="Два"/>
</DataTrigger>
<DataTrigger Value="3">
<Setter Property="Text" Value="Три"/>
</DataTrigger>
<DataTrigger Value="4">
<Setter Property="Text" Value="Четыре"/>
</DataTrigger>
<DataTrigger Value="">
<Setter Property="Text" Value=""/>
</DataTrigger>
</l:DataSwitch>
</Style.Triggers>
<Setter Property="Text" Value="Не могу понять"/>
</Style>
</TextBlock.Style>
</TextBlock>
Before: (BindingProxy) Start:(Overview) Next:(BoolExpressionConverter)