0
UWP:ToggleButton
のMouse OverとMouse Pressedの背景を削除するにはどうすればよいですか?UWP ToggleButtonのマウスオーバーとマウスが押された背景を削除する
XAML:
(PS:!これはButton
上で動作します)
<Style TargetType="ToggleButton">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Grid x:Name="RootGrid" Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
</VisualState>
<VisualState x:Name="PointerOver">
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentPresenter
x:Name="ContentPresenter"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTransitions="{TemplateBinding ContentTransitions}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw"
Foreground="White"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
結果(黒い四角の周囲とその中のやや暗い背景に注意してください):
同じボタンのもう1つの画像がチェックされていれば、恐ろしい見た目になるかもしれません。
は、私は強く、ハードにコーディングされたのではなく、その外観を制御するために、 'ToggleButton'のスタイリングを使って試してみることをお勧めしますこのような画像。 –