**編集 - 私はこれに対する答えとしてDynamicResourceの回答にフラグを立てました。これは私がここで説明した問題を解決しました。私は主なアプリケーションでまだ問題が発生していましたが、それは私がDynamicResourceとして私のボーダーで使用する前にブラシをStaticResourceとして使用していたためです。 DynamicResourceにすべてを切り替えたとき、正しく動作しました。ありがとう!WPF ToggleButton Template BorderBrush
BorderBrushがテンプレートのToggleButtonで動作するように見えません。ここに私のサンプル.xamlがあります。これを実行すると、マウスオーバーまたはボタンの1つをチェックすると、境界線が透明になることがわかります。四角形を使用して
<Window x:Class="ToggleButtonStyle.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:ToggleButtonStyle"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<!-- <ResourceDictionary Source="Dictionary1.xaml" /> -->
<!-- main color of buttons-->
<Color x:Key="MainThemeColor">Orange</Color>
<!-- hover-over color for buttons -->
<Color x:Key="MouseOverColor">Purple</Color>
<!-- 5. Mouse over background color for step buttons -->
<SolidColorBrush x:Key="MouseOverBackgroundBrush" Color="{DynamicResource MouseOverColor}"/>
<!-- 6. Background color active step -->
<SolidColorBrush x:Key="CheckedBackgroundBrush" Color="{DynamicResource MainThemeColor}"/>
<Style TargetType="{x:Type ToggleButton}" x:Key="ToggleButtonStyle">
<Setter Property="Background" Value="White" />
<Setter Property="Foreground" Value="Black" />
<Setter Property="Width" Value="Auto"/>
<Setter Property="Height" Value="40"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="MinWidth" Value="80"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness ="{TemplateBinding BorderThickness}" Padding="5" Margin="2">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="{StaticResource CheckedBackgroundBrush}" />
<Setter Property="Background" Value="{StaticResource MouseOverBackgroundBrush}" />
<Setter Property="Foreground" Value="#333333" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="BorderBrush" Value="{StaticResource MouseOverBackgroundBrush}"/>
<Setter Property="Background" Value="{StaticResource CheckedBackgroundBrush}" />
<Setter Property="Foreground" Value="#ffffff"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<StackPanel Orientation="Horizontal">
<ToggleButton Style="{DynamicResource ToggleButtonStyle}">Button 1</ToggleButton>
<ToggleButton Style="{DynamicResource ToggleButtonStyle}">Button 2</ToggleButton>
<ToggleButton Style="{DynamicResource ToggleButtonStyle}">Button 3</ToggleButton>
</StackPanel>
</Grid>
WPFインスペクタまたはVisual Studio 2015を使用して、ビジュアルツリーを表示できます。そこにはどのリソースが適用され、どのスタイルからであるかがわかります。 – Michael
私はそれをしました。 BorderBrushが "Transparent"であり、スタイルトリガーから来ているということだけです。 – MadSkeletor
静的リソースを参照するのではなく、BorderBrushセッターを特定の値に設定しようとする可能性があります。それが動作するかどうかを確認するだけです。 – Michael