【问题标题】:RadioButton has a white background when not focused?RadioButton 没有聚焦时有白色背景?
【发布时间】:2016-11-16 01:22:46
【问题描述】:

当我手动点击单选按钮时的单选按钮

当我按下另一个按钮来设置选择时,单选按钮

似乎是当单选按钮没有聚焦时然后得到这个白色方块

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”。但是,当我单击按钮时,它会更新选择,但不想要的副作用是我的单选按钮选择后面的白色方框。如何删除它?

【问题讨论】:

    标签: wpf radio-button .net-4.5


    【解决方案1】:

    我发现了问题,我需要将 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>
    

    【讨论】:

      猜你喜欢
      • 2020-08-19
      • 2015-08-15
      • 2018-08-06
      • 2023-01-26
      • 2013-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-10
      相关资源
      最近更新 更多