2012-03-21 8 views

答えて

-1

はいできます。あなたはラジオボタン用のxamlスタイルを作成する必要があります

+1

任意のサンプルは、非常に参考になります – user1102610

3

コピー/貼り付け/実行します。この愚かなサンプル:短い中

<Window x:Class="WpfApplication1.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="MainWindow" Height="350" Width="525"> 
<Window.Resources> 
    <Style TargetType="{x:Type RadioButton}"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="{x:Type RadioButton}"> 
        <StackPanel Orientation="Horizontal"> 
         <Polygon x:Name="star" Fill="Transparent" Stroke="Gray" StrokeThickness="2" Points="18,4 22,14 35,14 24,20 28,30 18,24 8,30 12,20 2,14 14,14"/> 
         <TextBlock Text="{TemplateBinding Content}" VerticalAlignment="Center" Margin="4,0"/> 
        </StackPanel> 
        <ControlTemplate.Triggers> 
         <Trigger Property="RadioButton.IsChecked" Value="True"> 
          <Setter TargetName="star" Property="Polygon.Fill" Value="Gold"/> 
         </Trigger> 
        </ControlTemplate.Triggers> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
</Window.Resources> 
<StackPanel> 
    <RadioButton Content="one" GroupName="sillySample" IsChecked="True" /> 
    <RadioButton Content="two" GroupName="sillySample"/> 
    <RadioButton Content="tree" GroupName="sillySample"/> 
</StackPanel> 

、あなたが好きで、内部統制構造を交換するために、いくつかのコントロールテンプレートを上書きすることができますWPFで、 (IsChecked)がテキストブロックまたはポリゴンのいずれにも属さないため、RadioButton.IsCheckedプロパティを使用してFill to Goldを設定していますが、私はまだこのままですできる私はラジオボタンのとにかくテンプレート

、幸運

デニスをオーバーライドしておりますので、それを使用することが

関連する問題