丸みのある境界線ボタンを作成しましたが、マウスオーバー時に背景色を変更できないようです。不透明度は変更されますが、背景色は変更されません。マウスオーバー時に背景色を変更します
<Style TargetType="Button" x:Key="FlatButtonStyle">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Name="border" BorderThickness="0" BorderBrush="Black" Background="{TemplateBinding Background}" CornerRadius="4">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Orange"/>
<Setter Property="Opacity" Value="0.91" />
</Trigger>
</Style.Triggers>
</Style>
ご覧のとおり、私は不透明度がなぜ機能するのか分からないのです。しかし、それは実際のボタン自体と競合していると思います。
<Button Style="{StaticResource FlatButtonStyle}" Content="Sign In" VerticalAlignment="Top" Margin="10,267,10,0" Background="#FF3650F3" Foreground="White" Height="29" Command="{Binding SignIn}">
これを無効にする方法はありますか?私がやってみたいのは、バックグラウンドをオレンジ色に変える一般的な丸みのあるボタンテンプレートを作成することです。しかし、自分のボタンに表示されているように、デフォルトの背景を設定する機能が必要です。
「オレンジ」色名を使用する代わりに、16進値を使用してみましたか? '#FFFFA500'のようなもの? –
@GeoffJamesはい私は持っていますが、何もありません。 – Dimitri
ここでこの答えを見ましたか?:http://stackoverflow.com/a/17259993/6240567 - 私はキーパーツが 'あなたの 'Style'宣言に入る –