【问题标题】:Can I wrap the Content/text value of a RadioButton in WPF?我可以在 WPF 中包装 RadioButton 的内容/文本值吗?
【发布时间】:2014-12-05 22:42:26
【问题描述】:

我有一些 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 属性?

【问题讨论】:

    标签: xaml radio-button textblock word-wrap


    【解决方案1】:

    您有一些选项,您可以在单选按钮样式模板中进行设置,以便它适用于所有选项,或者在实例级别快速执行;

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

    或者还有其他选择,如果有特定情况,请告诉我,我们会为您整理。

    【讨论】:

    • 谢谢,克里斯;我也必须添加一个 MaxWidth 值,但这很容易。
    猜你喜欢
    • 2010-12-12
    • 1970-01-01
    • 1970-01-01
    • 2014-08-09
    • 1970-01-01
    • 2022-10-15
    • 1970-01-01
    • 2021-04-22
    • 2021-08-28
    相关资源
    最近更新 更多