Can I wrap the Content/text value of a RadioButton in WPF?

无人久伴 提交于 2019-12-12 11:17:20

问题


I have some 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>

...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?


回答1:


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.



来源:https://stackoverflow.com/questions/27325859/can-i-wrap-the-content-text-value-of-a-radiobutton-in-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!