私はWPFアプリケーションのログインページで作業しています.ログインキーパッドボタンの背景画像を2つの異なる状態に変更したい. png)。これを作ってみたところ、ボタンを押すと背景ボタンが変化する(IsPressed Trigger)ことに成功したのですが、問題はデフォルトの背景画像にあるのでしょうか??
ボタンのデフォルトの背景画像を表示する方法は、ボタンを押すと別の背景画像に変わりますか?
ここに私のスタイルがあります:
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="border"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="1"
Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/RestaurantPOS;component/images/buttons/keypad_button_pressed.png"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" Value="0.25" />
<Setter Property="BorderBrush" Value="Transparent" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
これは私のキーパッド ボタンです: (スタイルはボタン番号 7 にのみ適用されます)
<Button x:Name="txb7" Click="txb7_Click" Content="7" HorizontalAlignment="Left" Margin="181,117,0,0" VerticalAlignment="Top" Width="72" Height="57" Style="{StaticResource ImageButton}" FontWeight="Bold" FontSize="18"></Button>
あなたが示しているように、ボタン番号7のデフォルトの背景は表示されません(青)が、それを押すと(keypad_button_pressed.png)が機能します。どうすればこの問題を解決できますか。
トグルボタンは使いたくない。