Home > Back-end >  How to change IsMouseOver style based on DataTrigger?
How to change IsMouseOver style based on DataTrigger?

Time:09-04

This code below changes the background on all states. How to change background to blue only when both IsMouseOver and DataTrigger is true?

<ControlTemplate.Triggers>

  <Trigger Property="IsMouseOver" Value="True">
    <Setter Property="Background" TargetName="Target1" Value="Red" />
  </Trigger>
                                
  <DataTrigger Binding = "{Binding ElementName = Import, Path = IsEnabled}" Value="true">
   <Setter Property="Background" TargetName="Target1" Value="Blue" />
  </DataTrigger>

</ControlTemplate.Triggers>

CodePudding user response:

You can do a MultiDataTrigger. Something like:

<MultiDataTrigger>               
    
    <MultiDataTrigger.Conditions>
        <Condition Binding="{Binding IsEnabled}" Value="True" />
        <Condition Binding="{Binding IsMouseOver}" Value="True" />
    </MultiDataTrigger.Conditions>
         
    <Setter Property="...." Value="...." />

</MultiDataTrigger>
  • Related