我可以在 WPF 中包装 RadioButton 的内容/文本值吗? [英] Can I wrap the Content/text value of a RadioButton in WPF?
问题描述
我有一些 XAML:
<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>
...其中,分配给 RadioButton 的内容的长字符串,它只是从地球边缘掉下来.如有必要,如何使用 TextBlock 的 TextWrapping 和 MaxWidth 属性将其包裹起来?或者我必须将 TextBlock 与每个 RadioButton 配对,避开 RadioButton 的 Content/Text 属性?
...where, with a long string assigned to a RadioButton's Content, it simply falls off the edge of the earth. How can I get it to wrap, if necessary, as I can with the TextWrapping and MaxWidth properties of TextBlock? Or must I pair a TextBlock with each RadioButton, eschewing the RadioButton's Content/Text property?
推荐答案
你有一些选择,你可以在 Radio Button Style Template 中让它这样做,以便它适用于所有这些,或者在实例级别只是一个快;
You have some options, you could go make it do so in the Radio Button Style Template so it applies to all of them, or at the instance level just a quick;
<RadioButton>
<RadioButton.Content>
<TextBlock Text="Wrap My Content Pretty Pretty Please" TextWrapping="Wrap"/>
</RadioButton.Content>
</RadioButton>
或者还有其他选择,如果有特定场景,请告诉我,我们会为您安排.
Or there's other options also, let me know if there's a specific scenario and we'll get ya sorted.
这篇关于我可以在 WPF 中包装 RadioButton 的内容/文本值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!