0
如何,即使按下按鈕後保持按鈕的背景顏色,現在我有按鈕的樣式,如下背景顏色在WPF
通過多觸發器使用IsPressed財產,我改變的背景按鈕的顏色,但我想即使按下按鈕,以表明按鈕被按下
<Style TargetType="{x:Type Button}" x:Key="Menubtn">
<Setter Property="Cursor" Value="Hand"></Setter>
<Setter Property="Height" Value="35"></Setter>
<Setter Property="Width" Value="125"></Setter>
<Setter Property="Margin" Value="10,0,0,0"></Setter>
<Setter Property="FontWeight" Value="DemiBold"></Setter>
<Setter Property="FontFamily" Value="Calibri"></Setter>
<Setter Property="FontSize" Value="15"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="VerticalAlignment" Value="Center"></Setter>
<Setter Property="Background" Value="#FF0080D4"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border BorderThickness="1" Background="#FF0080D4" x:Name="GridButton">
<Grid>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Width="Auto" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"></Condition>
<Condition Property="IsPressed" Value="True"></Condition>
<Condition Property="IsFocused" Value="True"></Condition>
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="#6D595C"></Setter>
<Setter Property="Background" TargetName="GridButton" Value="#EBEBEB"></Setter>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="false"></Condition>
<Condition Property="IsPressed" Value="false"></Condition>
<Condition Property="IsFocused" Value="false"></Condition>
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="Background" TargetName="GridButton" Value="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Background}" ></Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
聽起來像喲你應該使用ToggleButton,而不是Button。 – CodeNaked 2013-04-30 12:04:37