Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 709
B. Clay Shannon-B. Crow Raven Avatar asked Dec 05 '14 22:12

B. Clay Shannon-B. Crow Raven


People also ask

How do you wrap the content of a label in WPF?

In WPF, the Label control does not support text wrapping. If you need a label that wraps contents across multiple lines, you can use a TextBlock control. Place a TextBlock control inside a Label and apply wrapping on TextBlock.

What is Radiobutton WPF?

A Radio Button is a control that allows a user to select a single option from a group of options. The user is limited to select a single option from a related list of options which are mutually exclusive. It has only two options − Selected.


1 Answers

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.

like image 70
Chris W. Avatar answered Sep 22 '22 04:09

Chris W.