RadioButton 没有聚焦时有白色背景?
RadioButton has a white background when not focused?
手动点击单选按钮时的单选按钮
当我按下另一个按钮来设置选择时的单选按钮
似乎是当单选按钮没有聚焦时,然后将这个白色方框放在周围
RB 的样式:
<TextBlock Margin="0,0,0,0" Foreground="#FF3E3E3E" FontFamily="Calibri" FontSize="12">
<ContentPresenter />
</TextBlock>
</BulletDecorator>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="RadioMark" Property="Visibility" Value="Visible"/>
<Setter TargetName="RadioOuter" Property="BorderBrush" Value="Yellow" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
列表框:
<ListBox Background="Transparent" BorderThickness="0" ItemsSource="{Binding WhatsNewList}" SelectedItem="{Binding SelectedItem}">
<ListBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
</ListBox.Resources>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"
VerticalAlignment="Center"
HorizontalAlignment="Center">
</StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type local:ExampleClass}">
<RadioButton GroupName="Properties" Background="Transparent">
<RadioButton.IsChecked>
<Binding Path="IsSelected"
RelativeSource="{RelativeSource AncestorType=ListBoxItem}"
Mode="TwoWay" />
</RadioButton.IsChecked>
</RadioButton>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我有一个按钮,可以通过编程方式更改列表框上的 "SelectedItem"。但是,当我单击该按钮时,它会更新选择,但一个不需要的副作用是我的单选按钮选择后面出现一个白色方框。我该如何删除它?
我发现了问题,我需要将 InactiveSelectionHighlightBrushKey 颜色更改为透明
<ListBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" Opacity=".4"/>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey }" Color="Transparent" Opacity=".4"/>
</ListBox.Resources>
手动点击单选按钮时的单选按钮
当我按下另一个按钮来设置选择时的单选按钮
似乎是当单选按钮没有聚焦时,然后将这个白色方框放在周围
RB 的样式:
<TextBlock Margin="0,0,0,0" Foreground="#FF3E3E3E" FontFamily="Calibri" FontSize="12">
<ContentPresenter />
</TextBlock>
</BulletDecorator>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="RadioMark" Property="Visibility" Value="Visible"/>
<Setter TargetName="RadioOuter" Property="BorderBrush" Value="Yellow" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
列表框:
<ListBox Background="Transparent" BorderThickness="0" ItemsSource="{Binding WhatsNewList}" SelectedItem="{Binding SelectedItem}">
<ListBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
</ListBox.Resources>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"
VerticalAlignment="Center"
HorizontalAlignment="Center">
</StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type local:ExampleClass}">
<RadioButton GroupName="Properties" Background="Transparent">
<RadioButton.IsChecked>
<Binding Path="IsSelected"
RelativeSource="{RelativeSource AncestorType=ListBoxItem}"
Mode="TwoWay" />
</RadioButton.IsChecked>
</RadioButton>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我有一个按钮,可以通过编程方式更改列表框上的 "SelectedItem"。但是,当我单击该按钮时,它会更新选择,但一个不需要的副作用是我的单选按钮选择后面出现一个白色方框。我该如何删除它?
我发现了问题,我需要将 InactiveSelectionHighlightBrushKey 颜色更改为透明
<ListBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" Opacity=".4"/>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey }" Color="Transparent" Opacity=".4"/>
</ListBox.Resources>