René Stalder
René Stalder

Reputation: 2546

Metro UI XAML TextBlock Background

I switched from C#/WPF to C#/MetroUI Development and realized that there are many differences in XAML. For example in MetroUI there isn't a background property on TextBlock or I'm too stupid to use it. So how would I realize such a style for my TextBlock, if there isn't such a property?

I want to have white text on a blue background but the background have to follow the paragraph. Is there something like ItemTemplate for TextBlocks or a similar control to realize this scenario?

enter image description here

Upvotes: 1

Views: 4823

Answers (2)

123 456 789 0
123 456 789 0

Reputation: 10865

Do they actually have to be textblock? I've searched the documentation for the Windows.UI.Xaml and it seems like the background property is only available for the objects that inherit from the Control class. Textblock inherits from the FrameworkElement.

If I were you I would just modify the TextBox style and make it look like a textblock since you already have a WPF experience, I'm assuming this should be relatively easy for you to style and achieve that behavior.

More information are found on the actual documentation: TextBlock Class and TextBox Class

Made a comparison from there since I was looking where is the Background property now in WinRT. Hope this helps!

Upvotes: 1

Filip Skakun
Filip Skakun

Reputation: 31724

I think you would have to play a bit with putting the TextBlocks inside of a Border or putting filled Rectangles behind the TextBlocks - after you are done figuring out where to put the line breaks in the stack of TextBlocks. WinRT XAML like Silverlight has fairly limited APIs to help you with such advanced formatting automatically.

Upvotes: 0

Related Questions