マウスが移動するときにボタンの背景、余白、前景を変更したいが、フォアグラウンドのみを変更する。あなたはスタイルがする何よりも優先されますこと、Margin
とBackground
でやったようプロパティは、属性に設定されている場合..WPFトリガーが機能しない
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:coupleofbuttons"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button x:Name="ButtonX" Margin="10,10,0,0" Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Height="46" Background="Green" BorderThickness="0,0,0,7">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="DarkGoldenrod"/>
<Setter Property="Foreground" Value="Green"/>
<Setter Property="Margin" Value="10,20,0,0"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</Grid>
</Window>
ありがとう、それは働いて、今私は "依存関係"を理解しています..ありがとう... –
@ YassirRabiea素晴らしい。問題が解決した場合は、正解としてください。 –