XAML 如何根据DataTrigger更改IsMouseOver样式?

sqougxex  于 2022-12-07  发布在  SEO
关注(0)|答案(1)|浏览(211)

下面的代码更改所有状态的背景。如何仅在IsMouseOver和DataTrigger都为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>
iq0todco

iq0todco1#

你可以做一个MultiDataTrigger,比如:

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

</MultiDataTrigger>

相关问题