TextBlock and Label

This is just a placeholder. Under construction . . .

The most common usages within BeginComposite . . . EndComposite include:
AddText( row, column, string )
AddLabel( row, column, string, Background brush )
AddLabel( row, column, string, Background brush, Foreground brush )

Note that TextBlock currently only supports a single Inline run. Also, you can't get the text by referencing the Text property. Use GetText() and SetText() extension methods respectively to get or set text on the 1st Inline Run.

There is nothing to prevent you from using a TextBlock with multiple Inline Runs, but there simply is no built-in support for this using the default methods for Text within WPF-CPS. In other words, you could build your own TextBlock with multiple Inline Runs with multiple font settings, etc. and add this TextBlock as a Child to any IParent. But there aren't currently any convenience methods to make this easier.

Label and TextBlock are nearly identical. Think of Label as more like Text in a rectangle with a Background color, and TextBlock as more just text, a single Inline Text Run.

To leverage an Effect, such as adding a DropShadow, use SetTextEffect:
.SetTextEffect<Canvas>(0, 0, new System.Windows.Media.Effects.DropShadowEffect())

To underline, get a handle to the TextBlock and use a TextDecoration:
myPanel.GetTextBlock<StackPanel>(myGuidKey, 0, 0).TextDecorations = TextDecorations.Underline;

Last edited Apr 7, 2014 at 11:46 PM by stagathome0069, version 4


No comments yet.