I have many components in my XAML, I need fire Trigger when one or many components has your value changed.
I not want use one PropertyChangedTrigger for each components, I want use one Trigger for all components.
thanks.
I have many components in my XAML, I need fire Trigger when one or many components has your value changed.
I not want use one PropertyChangedTrigger for each components, I want use one Trigger for all components.
thanks.
Yes, use a MultiDataTrigger. Here's an example from the linked MSDN documentation about how you can use this on multiple properties:
<Window.Resources>
<c:Places x:Key="PlacesData"/>
<Style TargetType="ListBoxItem">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=State}" Value="WA">
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=Name}" Value="Portland" />
<Condition Binding="{Binding Path=State}" Value="OR" />
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="Cyan" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
<DataTemplate DataType="{x:Type c:Place}">
<Canvas Width="160" Height="20">
<TextBlock FontSize="12"
Width="130" Canvas.Left="0" Text="{Binding Path=Name}"/>
<TextBlock FontSize="12" Width="30"
Canvas.Left="130" Text="{Binding Path=State}"/>
</Canvas>
</DataTemplate>
</Window.Resources>
<StackPanel>
<TextBlock FontSize="18" Margin="5" FontWeight="Bold"
HorizontalAlignment="Center">Data Trigger Sample</TextBlock>
<ListBox Width="180" HorizontalAlignment="Center" Background="Honeydew"
ItemsSource="{Binding Source={StaticResource PlacesData}}"/>
</StackPanel>
EDIT: Not the cleanest solution ever, but you could do something like this. Basically use the MultiDataTrigger to execute whenever any of the properties change. Then, you use a converter for a simple null check (or perhaps you could always return true in your case). That way, your value in the MultiDataTrigger is just True instead of a specific value.