Show / Hide Table of Contents

Class TextBlock

Provides a lightweight control for displaying small amounts of text.

Inheritance
System.Object
DependencyObject
UIElement
FrameworkElement
TextBlock
Inherited Members
FrameworkElement.LayoutUpdated
FrameworkElement.SizeChanged
FrameworkElement.ResourceLookupMode
FrameworkElement.StyleProperty
FrameworkElement.Style
FrameworkElement.DefaultStyleKeyProperty
FrameworkElement.DefaultStyleKey
FrameworkElement.OverridesDefaultStyleProperty
FrameworkElement.OverridesDefaultStyle
FrameworkElement.OnVisualParentChanged(DependencyObject)
FrameworkElement.Parent
FrameworkElement.AddLogicalChild(Object)
FrameworkElement.RemoveLogicalChild(Object)
FrameworkElement.LogicalChildren
FrameworkElement.TemplatedParent
FrameworkElement.Resources
FrameworkElement.IsLoaded
FrameworkElement.OnApplyTemplate()
FrameworkElement.SetBinding(DependencyProperty, BindingBase)
FrameworkElement.SetBinding(DependencyProperty, Binding)
FrameworkElement.GetBindingExpression(DependencyProperty)
FrameworkElement.Cursor
FrameworkElement.CursorProperty
FrameworkElement.ManageIsEnabled(Boolean)
FrameworkElement.FindName(String)
FrameworkElement.Name
FrameworkElement.NameProperty
FrameworkElement.DataContext
FrameworkElement.DataContextProperty
FrameworkElement.DataContextChanged
FrameworkElement.Triggers
FrameworkElement.FlowDirectionProperty
FrameworkElement.FlowDirection
FrameworkElement.LanguageProperty
FrameworkElement.Language
FrameworkElement.Tag
FrameworkElement.TagProperty
FrameworkElement.LoadedEvent
FrameworkElement.Loaded
FrameworkElement.Unloaded
FrameworkElement.BindingValidationError
FrameworkElement.ContextMenuProperty
FrameworkElement.ContextMenu
FrameworkElement.ContextMenuOpening
FrameworkElement.ToolTipProperty
FrameworkElement.ToolTip
FrameworkElement.INTERNAL_OnDetachedFromVisualTree()
FrameworkElement.Height
FrameworkElement.HeightProperty
FrameworkElement.Width
FrameworkElement.WidthProperty
FrameworkElement.HorizontalAlignment
FrameworkElement.HorizontalAlignmentProperty
FrameworkElement.VerticalAlignment
FrameworkElement.VerticalAlignmentProperty
FrameworkElement.Margin
FrameworkElement.MarginProperty
FrameworkElement.MinHeight
FrameworkElement.MinHeightProperty
FrameworkElement.MinWidth
FrameworkElement.MinWidthProperty
FrameworkElement.MaxHeight
FrameworkElement.MaxHeightProperty
FrameworkElement.MaxWidth
FrameworkElement.MaxWidthProperty
FrameworkElement.ActualWidthProperty
FrameworkElement.ActualWidth
FrameworkElement.ActualHeightProperty
FrameworkElement.ActualHeight
UIElement.TransformToVisual(UIElement)
UIElement.RenderSize
UIElement.DesiredSize
UIElement.InvalidateMeasure()
UIElement.InvalidateArrange()
UIElement.Measure(Size)
UIElement.Arrange(Rect)
UIElement.UpdateLayout()
UIElement.DragEnter
UIElement.DragLeave
UIElement.Drop
UIElement.DragOver
UIElement.CacheMode
UIElement.CacheModeProperty
UIElement.Projection
UIElement.ProjectionProperty
UIElement.VisualParent
UIElement.AddVisualChild(UIElement)
UIElement.RemoveVisualChild(UIElement)
UIElement.OnVisualChildrenChanged(DependencyObject, DependencyObject)
UIElement.XamlSourcePath
UIElement.ClipToBounds
UIElement.ClipToBoundsProperty
UIElement.ClipProperty
UIElement.Clip
UIElement.IsEnabledProperty
UIElement.IsEnabled
UIElement.IsEnabledChanged
UIElement.EffectProperty
UIElement.Effect
UIElement.RenderTransformProperty
UIElement.RenderTransform
UIElement.RenderTransformOriginProperty
UIElement.RenderTransformOrigin
UIElement.UseLayoutRounding
UIElement.UseLayoutRoundingProperty
UIElement.Visibility
UIElement.VisibilityProperty
UIElement.IsVisibleProperty
UIElement.IsVisible
UIElement.IsVisibleChanged
UIElement.OpacityProperty
UIElement.Opacity
UIElement.OpacityMaskProperty
UIElement.OpacityMask
UIElement.IsHitTestVisible
UIElement.IsHitTestVisibleProperty
UIElement.AllowDrop
UIElement.AllowDropProperty
UIElement.CaptureMouse()
UIElement.IsMouseCaptured
UIElement.ReleaseMouseCapture()
UIElement.AllowScrollOnTouchMove
UIElement.AllowScrollOnTouchMoveProperty
UIElement.AddHandler(RoutedEvent, Delegate, Boolean)
UIElement.RemoveHandler(RoutedEvent, Delegate)
UIElement.MouseMoveEvent
UIElement.MouseMove
UIElement.OnMouseMove(MouseEventArgs)
UIElement.MouseLeftButtonDownEvent
UIElement.MouseLeftButtonDown
UIElement.OnMouseLeftButtonDown(MouseButtonEventArgs)
UIElement.MouseRightButtonDownEvent
UIElement.MouseRightButtonDown
UIElement.OnMouseRightButtonDown(MouseButtonEventArgs)
UIElement.MouseWheelEvent
UIElement.MouseWheel
UIElement.OnMouseWheel(MouseWheelEventArgs)
UIElement.MouseLeftButtonUpEvent
UIElement.MouseLeftButtonUp
UIElement.OnMouseLeftButtonUp(MouseButtonEventArgs)
UIElement.MouseEnterEvent
UIElement.MouseEnter
UIElement.OnMouseEnter(MouseEventArgs)
UIElement.MouseLeaveEvent
UIElement.MouseLeave
UIElement.OnMouseLeave(MouseEventArgs)
UIElement.TextInputStartEvent
UIElement.TextInputStart
UIElement.OnTextInputStart(TextCompositionEventArgs)
UIElement.TextInputEvent
UIElement.TextInput
UIElement.OnTextInput(TextCompositionEventArgs)
UIElement.TextInputUpdateEvent
UIElement.TextInputUpdate
UIElement.TappedEvent
UIElement.Tapped
UIElement.OnTapped(TappedRoutedEventArgs)
UIElement.MouseRightButtonUpEvent
UIElement.MouseRightButtonUp
UIElement.OnMouseRightButtonUp(MouseButtonEventArgs)
UIElement.KeyDownEvent
UIElement.KeyDown
UIElement.OnKeyDown(KeyEventArgs)
UIElement.KeyUpEvent
UIElement.KeyUp
UIElement.OnKeyUp(KeyEventArgs)
UIElement.GotFocusEvent
UIElement.GotFocus
UIElement.OnGotFocus(RoutedEventArgs)
UIElement.LostFocusEvent
UIElement.LostFocus
UIElement.OnLostFocus(RoutedEventArgs)
UIElement.LostMouseCapture
UIElement.OnLostMouseCapture(MouseEventArgs)
UIElement.INTERNAL_AttachToDomEvents()
UIElement.INTERNAL_DetachFromDomEvents()
DependencyObject.GetValue(DependencyProperty)
DependencyObject.SetCurrentValue(DependencyProperty, Object)
DependencyObject.ReadLocalValue(DependencyProperty)
DependencyObject.SetValue(DependencyProperty, Object)
DependencyObject.SetValue(DependencyPropertyKey, Object)
DependencyObject.CoerceValue(DependencyProperty)
DependencyObject.Dispatcher
DependencyObject.ClearValue(DependencyProperty)
DependencyObject.ClearValue(DependencyPropertyKey)
DependencyObject.CheckAccess()
DependencyObject.GetAnimationBaseValue(DependencyProperty)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: System.Windows.Controls
Assembly: OpenSilver.dll
Syntax
public class TextBlock : FrameworkElement, IFrameworkElement, IUIElement, IDependencyObject
Examples
TextBlockName.Text = "Some text.";

Constructors

| Improve this Doc View Source

TextBlock()

Declaration
public TextBlock()

Fields

| Improve this Doc View Source

CharacterSpacingProperty

Identifies the CharacterSpacing dependency property.

Declaration
public static readonly DependencyProperty CharacterSpacingProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

FontFamilyProperty

Identifies the FontFamily dependency property.

Declaration
public static readonly DependencyProperty FontFamilyProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

FontSizeProperty

Identifies the FontSize dependency property.

Declaration
public static readonly DependencyProperty FontSizeProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

FontStretchProperty

Identifies the FontStretch dependency property.

Declaration
[NotImplemented]
public static readonly DependencyProperty FontStretchProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

FontStyleProperty

Identifies the FontStyle dependency property.

Declaration
public static readonly DependencyProperty FontStyleProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

FontWeightProperty

Identifies the FontWeight dependency property.

Declaration
public static readonly DependencyProperty FontWeightProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

ForegroundProperty

Identifies the Foreground dependency property.

Declaration
public static readonly DependencyProperty ForegroundProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

LineHeightProperty

Identifies the LineHeight dependency property.

Declaration
public static readonly DependencyProperty LineHeightProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

LineStackingStrategyProperty

Identifies the LineStackingStrategy dependency property.

Declaration
public static readonly DependencyProperty LineStackingStrategyProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

PaddingProperty

Identifies the Padding dependency property.

Declaration
public static readonly DependencyProperty PaddingProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

TextAlignmentProperty

Identifies the TextAlignment dependency property.

Declaration
public static readonly DependencyProperty TextAlignmentProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

TextDecorationsProperty

Identifies the TextDecorations dependency property.

Declaration
public static readonly DependencyProperty TextDecorationsProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

TextProperty

Identifies the Text dependency property.

Declaration
public static readonly DependencyProperty TextProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

TextTrimmingProperty

Identifies the TextTrimming dependency property.

Declaration
public static readonly DependencyProperty TextTrimmingProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

TextWrappingProperty

Identifies the TextWrapping dependency property.

Declaration
public static readonly DependencyProperty TextWrappingProperty
Field Value
Type Description
DependencyProperty

Properties

| Improve this Doc View Source

BaselineOffset

Returns a value by which each line of text is offset from a baseline.

Declaration
public double BaselineOffset { get; }
Property Value
Type Description
System.Double

The amount by which each line of text is offset from the baseline, in device independent pixels. System.Double.NaN indicates that an optimal baseline offset is automatically calculated from the current font characteristics. The default is 0.0.

| Improve this Doc View Source

CharacterSpacing

Gets or sets the distance between characters of text in the control measured in 1000ths of the font size.

Declaration
public int CharacterSpacing { get; set; }
Property Value
Type Description
System.Int32

The distance between characters of text in the control measured in 1000ths of the font size. The default is 0.

| Improve this Doc View Source

FontFamily

Gets or sets the preferred top-level font family for the text content in this element.

Declaration
public FontFamily FontFamily { get; set; }
Property Value
Type Description
FontFamily

A FontFamily object that specifies the preferred font family, or a primary preferred font family with one or more fallback font families. For information about defaults, see the FontFamily class topic.

Exceptions
Type Condition
System.ArgumentNullException

FontFamily is null.

| Improve this Doc View Source

FontSize

Gets or sets the font size for the text content in this element.

Declaration
public double FontSize { get; set; }
Property Value
Type Description
System.Double

A non-negative value that specifies the font size, measured in pixels. The default is 11.

| Improve this Doc View Source

FontSource

Gets or sets the font source that is applied to the text for rendering content.

Declaration
[NotImplemented]
public FontSource FontSource { get; set; }
Property Value
Type Description
FontSource

The font source that is used to render content in the text box. The default is null.

| Improve this Doc View Source

FontStretch

Gets or sets the font stretch for the text content in this element.

Declaration
[NotImplemented]
public FontStretch FontStretch { get; set; }
Property Value
Type Description
FontStretch

The requested font stretch, which is a FontStretch that is obtained from one of the FontStretches property values. The default is Normal.

| Improve this Doc View Source

FontStyle

Gets or sets the font style for the content in this element.

Declaration
public FontStyle FontStyle { get; set; }
Property Value
Type Description
FontStyle

The requested font style, which is a FontStyle that is obtained from one of the FontStyles property values. The default is Normal.

| Improve this Doc View Source

FontWeight

Gets or sets the top-level font weight for the TextBlock.

Declaration
public FontWeight FontWeight { get; set; }
Property Value
Type Description
FontWeight

The requested font weight, which is a FontWeight that is obtained from one of the FontWeights property values. The default is Normal.

| Improve this Doc View Source

Foreground

Gets or sets the Brush to apply to the text contents of the TextBlock.

Declaration
public Brush Foreground { get; set; }
Property Value
Type Description
Brush

The brush used to apply to the text contents. The default is a SolidColorBrush with a Color value of Black.

| Improve this Doc View Source

Inlines

Gets the collection of inline text elements within a TextBlock.

Declaration
public InlineCollection Inlines { get; }
Property Value
Type Description
InlineCollection

A collection that holds all inline text elements from the TextBlock.The default is an empty collection.

| Improve this Doc View Source

LineHeight

Gets or sets the height of each line of content.

Declaration
public double LineHeight { get; set; }
Property Value
Type Description
System.Double

The height of each line in pixels. A value of 0 indicates that the line height is determined automatically from the current font characteristics. The default is 0.

Exceptions
Type Condition
System.ArgumentException

LineHeight is set to a non-positive value.

| Improve this Doc View Source

LineStackingStrategy

Gets or sets a value that indicates how a line box is determined for each line of text in the TextBlock.

Declaration
public LineStackingStrategy LineStackingStrategy { get; set; }
Property Value
Type Description
LineStackingStrategy

A value that indicates how a line box is determined for each line of text in the TextBlock. The default is MaxHeight.

| Improve this Doc View Source

Padding

Gets or sets a value that indicates the thickness of padding space between the boundaries of the content area and the content displayed by a TextBlock.

Declaration
public Thickness Padding { get; set; }
Property Value
Type Description
Thickness

A Thickness structure that specifies the amount of padding to apply.

| Improve this Doc View Source

Text

Gets or sets the text contents of a TextBlock.

Declaration
public string Text { get; set; }
Property Value
Type Description
System.String

A string that specifies the text contents of this TextBlock. The default is an empty string.

| Improve this Doc View Source

TextAlignment

Gets or sets a value that indicates the horizontal alignment of text content.

Declaration
public TextAlignment TextAlignment { get; set; }
Property Value
Type Description
TextAlignment

The text alignment. The default is Left.

| Improve this Doc View Source

TextDecorations

Gets or sets a value that specifies the text decorations that are applied to the content in a TextBlock element.

Declaration
public TextDecorationCollection TextDecorations { get; set; }
Property Value
Type Description
TextDecorationCollection

A TextDecorationCollection, or null if no text decorations are applied.

| Improve this Doc View Source

TextTrimming

Gets or sets the text trimming behavior to employ when content overflows the content area.

Declaration
public TextTrimming TextTrimming { get; set; }
Property Value
Type Description
TextTrimming

One of the TextTrimming values that specifies the text trimming behavior to employ. The default is None.

| Improve this Doc View Source

TextWrapping

Gets or sets how the TextBlock wraps text.

Declaration
public TextWrapping TextWrapping { get; set; }
Property Value
Type Description
TextWrapping

A value that indicates how the TextBlock wraps text. The default is NoWrap.

| Improve this Doc View Source

VisualChildrenCount

Declaration
protected override int VisualChildrenCount { get; }
Property Value
Type Description
System.Int32
Overrides
FrameworkElement.VisualChildrenCount

Methods

| Improve this Doc View Source

ArrangeOverride(Size)

Declaration
protected override Size ArrangeOverride(Size finalSize)
Parameters
Type Name Description
Size finalSize
Returns
Type Description
Size
Overrides
FrameworkElement.ArrangeOverride(Size)
| Improve this Doc View Source

CreateDomElement(Object, out Object)

Declaration
public override object CreateDomElement(object parentRef, out object domElementWhereToPlaceChildren)
Parameters
Type Name Description
System.Object parentRef
System.Object domElementWhereToPlaceChildren
Returns
Type Description
System.Object
Overrides
FrameworkElement.CreateDomElement(Object, out Object)
| Improve this Doc View Source

GetCharacterSpacing(DependencyObject)

Returns the value of the CharacterSpacing attached property for a specified dependency object.

Declaration
public static int GetCharacterSpacing(DependencyObject element)
Parameters
Type Name Description
DependencyObject element

The dependency object from which to retrieve the value of the CharacterSpacing attached property.

Returns
Type Description
System.Int32

The current value of the CharacterSpacing attached property on the specified dependency object.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

GetFontFamily(DependencyObject)

Returns the value of the FontFamily attached property for a specified dependency object.

Declaration
public static FontFamily GetFontFamily(DependencyObject element)
Parameters
Type Name Description
DependencyObject element

The dependency object for which to retrieve the value of the FontFamily property.

Returns
Type Description
FontFamily

The current value of the FontFamily attached property on the specified dependency object.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

GetFontSize(DependencyObject)

Returns the value of the FontSize attached property for a specified dependency object.

Declaration
public static double GetFontSize(DependencyObject element)
Parameters
Type Name Description
DependencyObject element

The dependency object for which to retrieve the value of the FontSize property.

Returns
Type Description
System.Double

The current value of the FontSize attached property on the specified dependency object.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

GetFontStretch(DependencyObject)

Returns the value of the FontStretch attached property for a specified dependency object.

Declaration
[NotImplemented]
public static FontStretch GetFontStretch(DependencyObject element)
Parameters
Type Name Description
DependencyObject element

The dependency object for which to retrieve the value of the FontStretch property.

Returns
Type Description
FontStretch

The current value of the FontStretch attached property on the specified dependency object.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

GetFontStyle(DependencyObject)

Returns the value of the FontStyle attached property for a specified dependency object.

Declaration
public static FontStyle GetFontStyle(DependencyObject element)
Parameters
Type Name Description
DependencyObject element

The dependency object for which to retrieve the value of the FontStyle property.

Returns
Type Description
FontStyle

The current value of the FontStyle attached property on the specified dependency object.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

GetFontWeight(DependencyObject)

Returns the value of the FontWeight attached property for a specified dependency object.

Declaration
public static FontWeight GetFontWeight(DependencyObject element)
Parameters
Type Name Description
DependencyObject element

The dependency object for which to retrieve the value of the FontWeight property.

Returns
Type Description
FontWeight

The current value of the FontWeight attached property on the specified dependency object.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

GetForeground(DependencyObject)

Returns the value of the Foreground attached property for a specified dependency object.

Declaration
public static Brush GetForeground(DependencyObject element)
Parameters
Type Name Description
DependencyObject element

The dependency object for which to retrieve the value of the Foreground property.

Returns
Type Description
Brush

The current value of the Foreground attached property on the specified dependency object.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

GetLineHeight(DependencyObject)

Returns the value of the LineHeight attached property for a specified dependency object.

Declaration
public static double GetLineHeight(DependencyObject element)
Parameters
Type Name Description
DependencyObject element

The dependency object from which to retrieve the value of the LineHeight property.

Returns
Type Description
System.Double

The current value of the LineHeight attached property on the specified dependency object.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

GetLineStackingStrategy(DependencyObject)

Returns the value of the LineStackingStrategy attached property for a specified dependency object.

Declaration
public static LineStackingStrategy GetLineStackingStrategy(DependencyObject element)
Parameters
Type Name Description
DependencyObject element

The dependency object from which to retrieve the value of the LineStackingStrategy attached property.

Returns
Type Description
LineStackingStrategy

The current value of the LineStackingStrategy attached property on the specified dependency object.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

GetTextAlignment(DependencyObject)

Returns the value of the TextAlignment attached property for a specified dependency object.

Declaration
public static TextAlignment GetTextAlignment(DependencyObject element)
Parameters
Type Name Description
DependencyObject element

The dependency object from which to retrieve the value of the TextAlignment property.

Returns
Type Description
TextAlignment

The current value of the TextAlignment attached property on the specified dependency object.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

GetVisualChild(Int32)

Declaration
protected override UIElement GetVisualChild(int index)
Parameters
Type Name Description
System.Int32 index
Returns
Type Description
UIElement
Overrides
FrameworkElement.GetVisualChild(Int32)
| Improve this Doc View Source

INTERNAL_OnAttachedToVisualTree()

Declaration
protected override void INTERNAL_OnAttachedToVisualTree()
Overrides
FrameworkElement.INTERNAL_OnAttachedToVisualTree()
| Improve this Doc View Source

MeasureOverride(Size)

Declaration
protected override Size MeasureOverride(Size availableSize)
Parameters
Type Name Description
Size availableSize
Returns
Type Description
Size
Overrides
FrameworkElement.MeasureOverride(Size)
| Improve this Doc View Source

OnCreateAutomationPeer()

Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
Type Description
AutomationPeer
Overrides
UIElement.OnCreateAutomationPeer()
| Improve this Doc View Source

OnPropertyChanged(DependencyPropertyChangedEventArgs)

Invoked whenever the effective value of any dependency property on this DependencyObject has been updated. The specific dependency property that changed is reported in the event data.

Declaration
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type Name Description
DependencyPropertyChangedEventArgs e

Event data that will contain the dependency property identifier of interest, the property metadata for the type, and old and new values.

Overrides
FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs)
| Improve this Doc View Source

SetCharacterSpacing(DependencyObject, Int32)

Sets the value of the CharacterSpacing attached property on a specified dependency object.

Declaration
public static void SetCharacterSpacing(DependencyObject element, int value)
Parameters
Type Name Description
DependencyObject element

The dependency object on which to set the value of the CharacterSpacing property.

System.Int32 value

The new value to set the property to.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

SetFontFamily(DependencyObject, FontFamily)

Sets the value of the FontFamily attached property for a specified dependency object.

Declaration
public static void SetFontFamily(DependencyObject element, FontFamily value)
Parameters
Type Name Description
DependencyObject element

The dependency object for which to set the value of the FontFamily property.

FontFamily value

The new value to set the property to.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

SetFontSize(DependencyObject, Double)

Sets the value of the FontSize attached property for a specified dependency object.

Declaration
public static void SetFontSize(DependencyObject element, double value)
Parameters
Type Name Description
DependencyObject element

The dependency object for which to set the value of the FontSize property.

System.Double value

The new value to set the property to.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

SetFontStretch(DependencyObject, FontStretch)

Sets the value of the FontStretch attached property for a specified dependency object.

Declaration
[NotImplemented]
public static void SetFontStretch(DependencyObject element, FontStretch value)
Parameters
Type Name Description
DependencyObject element

The dependency object for which to set the value of the FontStretch property.

FontStretch value

The new value to set the property to.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

SetFontStyle(DependencyObject, FontStyle)

Sets the value of the FontStyle attached property for a specified dependency object.

Declaration
public static void SetFontStyle(DependencyObject element, FontStyle value)
Parameters
Type Name Description
DependencyObject element

The dependency object for which to set the value of the FontStyle property.

FontStyle value

The new value to set the property to.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

SetFontWeight(DependencyObject, FontWeight)

Sets the value of the FontWeight attached property for a specified dependency object.

Declaration
public static void SetFontWeight(DependencyObject element, FontWeight value)
Parameters
Type Name Description
DependencyObject element

The dependency object for which to set the value of the FontWeight property.

FontWeight value

The new value to set the property to.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

SetForeground(DependencyObject, Brush)

Sets the value of the Foreground attached property for a specified dependency object.

Declaration
public static void SetForeground(DependencyObject element, Brush value)
Parameters
Type Name Description
DependencyObject element

The dependency object for which to set the value of the Foreground property.

Brush value

The new value to set the property to.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

SetLineHeight(DependencyObject, Double)

Sets the value of the LineHeight attached property for a specified dependency object.

Declaration
public static void SetLineHeight(DependencyObject element, double value)
Parameters
Type Name Description
DependencyObject element

The dependency object on which to set the value of the LineHeight property.

System.Double value

The new value to set the property to.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

System.ArgumentException

value is negative.

| Improve this Doc View Source

SetLineStackingStrategy(DependencyObject, LineStackingStrategy)

Sets the value of the LineStackingStrategy attached property on a specified dependency object.

Declaration
public static void SetLineStackingStrategy(DependencyObject element, LineStackingStrategy value)
Parameters
Type Name Description
DependencyObject element

The dependency object on which to set the value of the LineStackingStrategy property.

LineStackingStrategy value

The new value to set the property to.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

| Improve this Doc View Source

SetTextAlignment(DependencyObject, TextAlignment)

Sets the value of the TextAlignment attached property for a specified dependency object.

Declaration
public static void SetTextAlignment(DependencyObject element, TextAlignment value)
Parameters
Type Name Description
DependencyObject element

The dependency object on which to set the value of the TextAlignment property.

TextAlignment value

The new value to set the property to.

Exceptions
Type Condition
System.ArgumentNullException

element is null.

Extension Methods

DependencyObjectHelper.GetSelfAndAncestors(DependencyObject)
UIElementExtendedRoutedEventExtensions.AddHandler(UIElement, ExtendedRoutedEvent, Delegate, Boolean)
UIElementExtendedRoutedEventExtensions.RemoveHandler(UIElement, ExtendedRoutedEvent, Delegate)
VisualTreeExtensions.GetVisualAncestors(DependencyObject)
VisualTreeExtensions.GetVisualAncestorsAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualChildren(DependencyObject)
VisualTreeExtensions.GetVisualChildrenAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualDescendants(DependencyObject)
VisualTreeExtensions.GetVisualDescendantsAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualSiblings(DependencyObject)
VisualTreeExtensions.GetVisualSiblingsAndSelf(DependencyObject)
VisualTreeExtensions.GetBoundsRelativeTo(FrameworkElement, UIElement)
VisualTreeExtensions.InvokeOnLayoutUpdated(FrameworkElement, Action)
  • Improve this Doc
  • View Source