我正在尝试实现附件中显示的效果,但没有成功。甚至有可能吗?我试图将文本框放在单选按钮内,并将其设置为水平和垂直内容对齐,但它没有按我想要的方式工作。
欢迎任何建议。
Resource
<Window.Resources>
<Style x:Key="RadioButton" TargetType="RadioButton">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<StackPanel>
<TextBlock FontFamily="Segoe Ui Dark" HorizontalAlignment="Center" Foreground="Black" Text="{TemplateBinding Content}" FontSize="12" FontWeight="SemiBold" Margin="0,0,0,2" />
<BulletDecorator Grid.Column="0" Background="Transparent" >
<BulletDecorator.Bullet>
<Grid Width="14" Height="14" >
<Ellipse x:Name="Border" Fill="Transparent" StrokeThickness="1" Stroke="Black" />
<Ellipse x:Name="CheckMark" Margin="4" Fill="Black"/>
</Grid>
</BulletDecorator.Bullet>
</BulletDecorator>
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="false">
<Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="Border" Property="Fill" Value="LightGray" />
<Setter TargetName="Border" Property="Stroke" Value="Black" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="Border" Property="Fill" Value="White" />
<Setter TargetName="Border" Property="Stroke" Value="Black" />
<Setter TargetName="Border" Property="StrokeThickness" Value="4" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
Xaml
<StackPanel Orientation="Horizontal">
<RadioButton Content="1" Style="{StaticResource RadioButton}" Margin="5"></RadioButton>
<RadioButton Content="2" Style="{StaticResource RadioButton}" Margin="5"></RadioButton>
<RadioButton Content="3" Style="{StaticResource RadioButton}" Margin="5"></RadioButton>
<RadioButton Content="4" Style="{StaticResource RadioButton}" Margin="5" ></RadioButton>
<RadioButton Content="5" Style="{StaticResource RadioButton}" Margin="5"></RadioButton>
</StackPanel>
Result
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)