ボタン、エキスパンダー、および1-N個のボタンが追加されたポップアップで構成された自分の「分割ボタン」を巻きました。今すぐポップアップのボタンは、彼らの周りに非常に厚い境界に来るボタンのスタイルは、BorderThickness = "0"を持っています。ボタンがポップアップしているので、境界線が設定されている可能性があります。私の質問は:他のすべてのボタンスタイルの "プロパティ"がオーバーライドされないように境界をオーバーライドする方法ですか?WPFポップアップでボタンのスタックのための唯一のボーダー設定(太さ/ブラシ)をオーバーライドする方法?
<Popup
IsOpen="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type my:SplitButton}}, Path=IsExpanded}"
PlacementTarget="{Binding ElementName=Button}"
PopupAnimation="Fade"
StaysOpen="False"
>
<Popup.Resources>
<Style TargetType="Border">
<Setter Property="BorderThickness" Value="0" />
</Style>
</Popup.Resources>
<ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type my:SplitButton}}, Path=ItemsSource}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Content="{Binding Converter={ui:ConvertObjectToResource}}" Tag="{Binding}" Click="Control_Click" BorderThickness="0"
Width="{Binding ActualWidth, ElementName=WidthButton}">
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Popup>
編集:私は実際にこのように行うことができます。
<Popup.Resources>
<Style TargetType="Button">
<Setter Property="BorderThickness" Value="0" />
</Style>
</Popup.Resources>
これは、残念ながら(パディング及び背景、フォアグラウンドのように)、ボタンの他のすべてのスタイルプロパティをオーバーライドします。
私はまた、次のように行うことができます。
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Content="{Binding Converter={ui:ConvertObjectToResource}}" Tag="{Binding}" Click="Control_Click"
Width="{Binding ActualWidth, ElementName=WidthButton}">
<Button.Style>
<Style TargetType="Button">
<Setter Property="BorderThickness" Value="0"></Setter>
<Setter Property="BorderBrush" Value="Transparent"></Setter>
</Style>
</Button.Style>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
だけでなく、ボタンのスタイルを上書きしています。 BasedOn = "ButtonsNormalStyleHere"に設定することで取り組もうとすると、境界線が再び現れます。つまり、BorderThicknessとBorderBrushは効果がありません。
コード[結果](http://screencast.com/t/ZzSCc5wJH)を私のためのボタンの周りにはっきりと表示しないでください。おそらくあなたはいくつかのスタイルが干渉しているかもしれません... – 3615
はい。もちろん私にはスタイルがあります。私はどのスタイルを知らない。私はそれを無効にしたいだけです。 –
さて、それは**まったく別の質問です。あなたが説明した問題を再現することはできません。不足しているスタイルを質問に追加します。 – 3615