2014-12-05 73 views
2

我有一些XAML:我可以在WPF中包裝RadioButton的內容/文本值嗎?

<StackPanel Orientation="Horizontal"> 
    <TextBlock x:Name="KeyLWP" TextWrapping="Wrap" MaxWidth="120">A Letter or Word or Phrase 
    </TextBlock> 
    <StackPanel> 
     <RadioButton x:Name="rdbtnCandidateVal1" Content="Two wrongs don't make a Wright Brothers Grimm was the Thingamabob Dylan Thomas Jefferson Airplane"> 
     </RadioButton> 

...其中,分配給一個單選按鈕的內容的長字符串,它只是脫落的地球的邊緣。如果需要,我如何使用TextBlock的TextWrapping和MaxWidth屬性來包裝它?或者我必須將TextBlock與每個RadioButton配對,避開RadioButton的Content/Text屬性?

回答

3

你有一些選擇,你可以在單選按鈕樣式模板中使它做到這一點,所以它適用於所有這些,或者在實例級別只是一個快速;

<RadioButton> 
    <RadioButton.Content> 
     <TextBlock Text="Wrap My Content Pretty Pretty Please" TextWrapping="Wrap"/> 
    </RadioButton.Content> 
</RadioButton> 

或者還有其他的選擇,讓我知道如果有一個特定的場景,我們會得到亞排序。

+0

謝謝,克里斯;我不得不添加一個MaxWidth val,但這很簡單。 – 2014-12-06 00:16:13

相關問題