0
Button
ControlTemplate
私はIsPressed
イベントにアクセスする必要があります。それ、どうやったら出来るの?WPFコントロールテンプレートによるクリック時のButto DropShadowEffectの削除
背景:私はをButton
Style
に追加しましたが、ぼやけたテキストがありました。 This fix solved the blurry text issue.しかし、これは新しい問題を追加しました。ユーザーがボタンをクリックすると、DropShadowEffect
を削除したかったのです。私はこれをそうするだろうと考えました。
<Style x:Key="DropShadowButtons" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Border Background="{TemplateBinding Background}">
<Border.Style>
<Style TargetType="{x:Type Border}">
<Setter Property="Border.Effect">
<Setter.Value>
<DropShadowEffect Color="Black" Opacity="0.5" />
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Button.IsPressed" Value="False">
<Setter Property="Border.Effect">
<Setter.Value>
<DropShadowEffect Color="Black" Direction="320" ShadowDepth="0" BlurRadius="0" Opacity="0" />
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</Border.Style>
</Border>
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,2,5,0"/>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
はその後Button.IsPressed
がBorder
の一部で発火しないことを考え出しました。では、ControlTemplateはButtonのIsPressedイベントにどのようにアクセスしますか?
ありがとうございました! –