WPF Trigger Property常用項具體舉例
阿新 • • 發佈:2018-11-03
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#ffF45F15" Offset="0"/>
<GradientStop Color="#ffFFA26D" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<!--<Setter Property="Foreground" Value="#ff1000F4"/> 對字型顏色進行更改設定-->
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#ffF4E989"/>
<!--<Setter TargetName="content" Property="RenderTransform" > 字型點選時候進行偏移
<Setter.Value>
<TranslateTransform Y="1.0" X="1.0" />
</Setter.Value>
</Setter>-->
</Trigger>
<Trigger Property="IsDefaulted" Value="True">
<Setter TargetName="border" Property="Background" Value="#ff44F439"/>
<Setter Property="Foreground" Value="#ffffffff"/>
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="border" Property="Background" Value="#ff44F439"/>
<Setter Property="Foreground" Value="#ffffffff"/>
</Trigger>
</ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#ffF45F15" Offset="0"/>
<GradientStop Color="#ffFFA26D" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<!--<Setter Property="Foreground" Value="#ff1000F4"/> 對字型顏色進行更改設定-->
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#ffF4E989"/>
<!--<Setter TargetName="content" Property="RenderTransform" > 字型點選時候進行偏移
<Setter.Value>
<TranslateTransform Y="1.0" X="1.0" />
<ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="border" Property="Background"> <Setter.Value> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#ffF45F15" Offset="0"/> <GradientStop Color="#ffFFA26D" Offset="1"/> </LinearGradientBrush> </Setter.Value> </Setter> <!--<Setter Property="Foreground" Value="#ff1000F4"/> 對字型顏色進行更改設定--> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter Property="Background" Value="#ffF4E989"/> <!--<Setter TargetName="content" Property="RenderTransform" > 字型點選時候進行偏移 <Setter.Value> <TranslateTransform Y="1.0" X="1.0" /> </Setter.Value> </Setter>--> </Trigger> <Trigger Property="IsDefaulted" Value="True"> <Setter TargetName="border" Property="Background" Value="#ff44F439"/> <Setter Property="Foreground" Value="#ffffffff"/> </Trigger> <Trigger Property="IsFocused" Value="True"> <Setter TargetName="border" Property="Background" Value="#ff44F439"/> <Setter Property="Foreground" Value="#ffffffff"/> </Trigger> </ControlTemplate.Triggers>
</Setter.Value>
</Setter>-->
</Trigger>
<Trigger Property="IsDefaulted" Value="True">
<Setter TargetName="border" Property="Background" Value="#ff44F439"/>
<Setter Property="Foreground" Value="#ffffffff"/>
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="border" Property="Background" Value="#ff44F439"/>
<Setter Property="Foreground" Value="#ffffffff"/>
</Trigger>
</ControlTemplate.Triggers>