XAML, dynamically created RadioButton, and WordWrap?

  • Thread starter Thread starter Tore Bostrup
  • Start date Start date
T

Tore Bostrup

I have an app that presents a variable number of radio buttons (with
variable text) that are created dynamically on a HeaderedItemsControl. As
far as I can tell, the RadioButton doesn't supports (word or otherwise)
wrapping, but will present multiple lines of text, so I could implement word
wrapping by inserting NewLine(s) if I could just determine how wide my text
is... It is occasionally too wide for a single line, and could
theoretically be several lines.

I would *really* like to do this when I create the controls and assign the
texts and handlers (this is after the window has been shown), but while I
can get the initial DesiredSize AND the first iteration after that, it seems
I can't get there from here: It won't tell me the size until the layout is
final - but the layout won't be final until I know the size of my display
text.

What can I do (.Net 2.0 w/FW 3.0, VB preferred, but except for some
differences in threading and delegates, I can deal with C#)?

TIA,
Tore
 
Well,

I don't know if the question was too dumb or whether there just aren't many
XAML folks on these lists, but I finally found my answer...

Instead of using a string as content, I added a TextBlock element containing
the string and with TextWrapping on:

Dim checkTextBlock As TextBlock = New TextBlock()

checkTextBlock.TextWrapping = TextWrapping.Wrap

checkTextBlock.Text = StripEndingLineFeeds(choice.Text)

checkAnswer.Content = checkTextBlock



This works like a charm, at least in a StackPanel, which may have been more
appropriate anyway.



Tore.
 
Back
Top