2017-04-17 12 views
-1
var item = new RadioButton { Content = "some_name"}; 
     item.Checked += radioButtonClick; 
     item.Unchecked += radioButtonUnClick; 

実際の表示はsomenameです。アンダースコアがありません。これを修正するには、ラジオボタンで次のスタイルを使用しましたが、副作用があります。ラジオボタンアイコンは表示されません。コードの下に使用してくださいradiobuttonunderscoreを表示するには、事前ラジオボタンテキストはアンダースコア(_)を表示しませんwpf

+1

の背後にあるコードの場合

<RadioButton ...... > <TextBlock Text="SELECT_ME" /> </RadioButton> 

あなたは実際、おそらく名前の変更が良いでしょう、タイトルに別の質問をされますか?:) –

+0

あなたはこのスタイルを使用しているラジオボタンのコードを追加し、 @Chrisは改名のタイトルが良いアイデアであることを示唆しています。 – tabby

答えて

0

<Style x:Key="{x:Type RadioButton}" TargetType="{x:Type RadioButton}"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="{x:Type RadioButton}"> 
        <Border Background="{TemplateBinding Background}" 
         BorderThickness="{TemplateBinding BorderThickness}" 
         BorderBrush="{TemplateBinding BorderBrush}" 
         Padding="{TemplateBinding Padding}" 
         SnapsToDevicePixels="true"> 
         <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
             VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
             RecognizesAccessKey="False" 
             SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> 
        </Border> 
        <ControlTemplate.Triggers> 
         <Trigger Property="IsEnabled" Value="false"> 
          <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" /> 
         </Trigger> 
        </ControlTemplate.Triggers> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 

感謝。

var item = new RadioButton { Content = new TextBlock { Text = "SELECT_ME" } }; 
+0

ありがとう..それは働いた! – user2131048

関連する問題