Question

I have a grid (layoutroot) of two columns. I have a list of checkboxes in each of these columns. If a checkbox is checked I need to add some text below it. I was unable to find a way to add a textbox below a checkbox dynamically which would not overlap with the checkbox right below it so I thought of adding the text to be added to the CheckBox text and when this text exceeds the width, it should move to a new line.

Now, this is not the case right now. The checkbox trims any text that is larger than its width. Is there are way to let a checkbox grow in height like a "cangrow" property of reports ? Or is there a workaround that would allow me to add a textbox in between two existing checkboxes and expanding the layout vertically ?

Thanks in advance

Was it helpful?

Solution

TextBlock has similar feature to what you refer as "cangrow" in reports. It is TextWrapping property. Therefore, you can set CheckBox's content to be a TextBlock control to achieve that growing text effect :

<CheckBox>
    <TextBlock TextWrapping="Wrap" Text="Some long text here"/>
</CheckBox>

OTHER TIPS

Add the TextBlock in the designer, then set it's visibility to collapsed. Then when you want to display it, set the visibility to visible.

<StackPanel>
<Checkbox />
<TextBlock x:Name="txtMessage" Visibility="Collapsed" Text="Your text here"/>
</StackPanel>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top