我正在尝试实现附加文件中显示的效果,但没有成功。甚至可能吗?我试图将文本框放在radiobutton中并设置为水平和垂直内容对齐,但它不能按我的意愿工作。 欢迎任何建议。
答案 0 :(得分:2)
<强>资源强>
<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>
<强>结果强>
答案 1 :(得分:1)
根据您的.Net版本,从http://msdn.microsoft.com/en-us/library/ms751600(v=vs.90).aspx下载模板。
现在根据您的要求进行更改。