2

I'm developing a Windows Phone 8 application. I've got a ContentControl:

<ContentControl Content="{Binding Text, Converter={StaticResource TextConverter}}" />

TextConverter converts plain text to formatted text, returning a TextBlock object. That works fine, but I need to apply additional formatting to this TextBlock. In WPF, I could do something like that:

<ContentControl Content="{Binding Text, Converter={StaticResource TextConverter}}" TextBlock.TextWrapping="Wrap" />

Unfortunately, that doesn't seem to work for WP8. How can I implement this kind of functionality in Windows Phone application?

admdrew
  • 3,790
  • 4
  • 27
  • 39
Olga Trikk
  • 21
  • 1
  • If you know you'll have text there, why do you need a ContentControl? Use a TextBlock instead. – Soonts Oct 23 '14 at 01:40
  • @Soonts, I would be happy if you told be how can I use just a TextBlock here instead of the ContentControl. The problem is that my Text property is actually a text containing certain tags. TextConverter formats the text according to these tags, so it doesn't return just text, it returns a TextBlock. How can I tell xaml that I want to have a TextBlock returned by TextConverter here, not using ContentControl? – Olga Trikk Oct 23 '14 at 05:15
  • The converters are for converting values into some other values, not for converting values into an arbitrary set of UI elements. If you need to produce custom visual tree from your data, just write a C# code for that, and call it. Here is my old example with TextBox formatting, BTW: http://stackoverflow.com/a/13566586/126995 If you love XAML and don’t want to call the code yourself, wrap it into a custom attached behavior, not into the value converter. – Soonts Oct 23 '14 at 21:55

0 Answers0