小编sri*_*vas的帖子

单选按钮样式作为 xaml 中的切换按钮

我有 2 个按钮应该充当开关,所以我使用单选按钮。但单选按钮的样式应该看起来像切换按钮,这意味着它不应该有一个圆圈可供检查。

我搜索了很长时间没有找到有用的资源。

<Style TargetType="{x:Type RadioButton}" BasedOn="{StaticResource {x:Type ToggleButton}}">
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style> 


    <Style TargetType="{x:Type ToggleButton}">
        <Setter Property="Background" Value="{StaticResource BgColor}" />
        <Setter Property="Foreground" Value="{StaticResource FgColor}" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Margin" Value="0" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="{StaticResource HoverColor}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="BorderBrush" Value="{StaticResource TextBlack}" />
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="BorderBrush" Value="{StaticResource TextBlack}" />
                <Setter Property="Foreground" Value="{StaticResource HoverColor}" />
            </Trigger>
        </Style.Triggers>
    </Style>
Run Code Online (Sandbox Code Playgroud)

但它为圆圈(单选属性)留下了一个黑色空间,并且在鼠标悬停时,它显示了要检查的圆圈。

谁能知道实现它的最简单方法..

xaml radio-button togglebutton

1
推荐指数
1
解决办法
2679
查看次数

标签 统计

radio-button ×1

togglebutton ×1

xaml ×1