<ListBox>
<ListBox.Triggers>
<DataTrigger Binding="{Binding IsListBoxEnabled}" Value="False">
...
</DataTrigger>
</ListBox.Triggers>
</ListBox>
If you try to add a DataTrigger to the ListBox.Triggers Collection, you will get the following
exception:
Triggers collection members must be of type EventTrigger.
Fortunately, there is a simple workaround to allow DataTriggers: using Style.Triggers!
<ListBox ItemsSource="{Binding KeyFrames}" >
<ListBox.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding IsListBoxEnabled}" Value="False">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation To="0.3"
Storyboard.TargetProperty="Opacity" Duration="0:0:0.400"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation To="1"
Storyboard.TargetProperty="Opacity" Duration="0:0:0.400"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</ListBox.Style>
</ListBox>
Keine Kommentare:
Kommentar veröffentlichen