2017-05-24 76 views
1

所以,可能是其如此愚蠢的問題,但我需要相同的單選按鈕,因爲這:WPF設置老式的單選按鈕

<ToolBar DockPanel.Dock="Top"> 
        <RadioButton x:Name="rbtnInkMode" VerticalAlignment="Top" GroupName="drawMode">Ink Mode!</RadioButton> 
        <RadioButton x:Name="rbtnEraseMode" VerticalAlignment="Top" GroupName="drawMode">Erase Mode!</RadioButton> 
        <RadioButton x:Name="rbtnSelectMode" VerticalAlignment="Top" GroupName="drawMode">Select Mode!</RadioButton> 
</ToolBar> 

![enter image description here

但是,當我在XAML文件中寫道我得到了沒想到結果:

![enter image description here

它的外觀當然更好,但我期望,並希望得到老收音機屁股就像在WinForms中一樣!我在C#中的Visual Studio 2015社區工作 - WPF項目。 如果有人知道如何通過簡單的方式返回單選按鈕的「舊式」(對於XAML初學者可以理解),請儘快回答這個問題!

+0

你可以給你的XAML,因爲上下文我使用了你的xaml,並得到了預期的[結果](http://imgur.com/a/L2yh9) – C1rdec

+1

你的單選按鈕似乎在工具欄內,並且工具欄正在覆蓋默認樣式。 – RogerN

+0

@NemoUA請將完整的xaml代碼添加到問題中。目前尚不清楚這個行爲可能出現在哪裏 –

回答

1

的原因是WPF工具欄模板樣式應用於單選按鈕:

"{StaticResource {x:Static ToolBar.RadioButtonStyleKey}}"

嘗試指定這樣的風格:

<RadioButton Style="{StaticResource {x:Type RadioButton}}" x:Name="rbtnInkMode" GroupName="drawMode">Ink Mode!</RadioButton> 
<RadioButton Style="{StaticResource {x:Type RadioButton}}" x:Name="rbtnEraseMode" GroupName="drawMode">Erase Mode!</RadioButton> 
<RadioButton Style="{StaticResource {x:Type RadioButton}}" x:Name="rbtnSelectMode" GroupName="drawMode">Select Mode!</RadioButton> 
+0

就是這樣!非常感謝你! – NemoUA