DashStyle Class
Represents the sequence of dashes and gaps that will be applied by a Pen.
Assembly: PresentationCore (in PresentationCore.dll)
| Name | Description | |
|---|---|---|
![]() | DashStyle() | Initializes a new instance of the DashStyle class. |
![]() | DashStyle(IEnumerable<Double>^, Double) |
| Name | Description | |
|---|---|---|
![]() | CanFreeze | Gets a value that indicates whether the object can be made unmodifiable. (Inherited from Freezable.) |
![]() | Dashes | Gets or sets the collection of dashes and gaps in this DashStyle. |
![]() | DependencyObjectType | Gets the DependencyObjectType that wraps the CLR type of this instance. (Inherited from DependencyObject.) |
![]() | Dispatcher | Gets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.) |
![]() | HasAnimatedProperties | Gets a value that indicates whether one or more AnimationClock objects is associated with any of this object's dependency properties.(Inherited from Animatable.) |
![]() | IsFrozen | Gets a value that indicates whether the object is currently modifiable. (Inherited from Freezable.) |
![]() | IsSealed | Gets a value that indicates whether this instance is currently sealed (read-only).(Inherited from DependencyObject.) |
![]() | Offset | Gets or sets how far in the dash sequence the stroke will start. |
| Name | Description | |
|---|---|---|
![]() | ApplyAnimationClock(DependencyProperty^, AnimationClock^) | Applies an AnimationClock to the specified DependencyProperty. If the property is already animated, the SnapshotAndReplace handoff behavior is used.(Inherited from Animatable.) |
![]() | ApplyAnimationClock(DependencyProperty^, AnimationClock^, HandoffBehavior) | Applies an AnimationClock to the specified DependencyProperty. If the property is already animated, the specified HandoffBehavior is used.(Inherited from Animatable.) |
![]() | BeginAnimation(DependencyProperty^, AnimationTimeline^) | Applies an animation to the specified DependencyProperty. The animation is started when the next frame is rendered. If the specified property is already animated, the SnapshotAndReplace handoff behavior is used.(Inherited from Animatable.) |
![]() | BeginAnimation(DependencyProperty^, AnimationTimeline^, HandoffBehavior) | Applies an animation to the specified DependencyProperty. The animation is started when the next frame is rendered. If the specified property is already animated, the specified HandoffBehavior is used. (Inherited from Animatable.) |
![]() | CheckAccess() | Determines whether the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.) |
![]() | ClearValue(DependencyProperty^) | Clears the local value of a property. The property to be cleared is specified by a DependencyProperty identifier. (Inherited from DependencyObject.) |
![]() | ClearValue(DependencyPropertyKey^) | Clears the local value of a read-only property. The property to be cleared is specified by a DependencyPropertyKey. (Inherited from DependencyObject.) |
![]() | Clone() | Creates a modifiable clone of this DashStyle, making deep copies of this object's values. |
![]() | CloneCurrentValue() | Creates a modifiable clone of this DashStyle object, making deep copies of this object's current values. |
![]() | CoerceValue(DependencyProperty^) | Coerces the value of the specified dependency property. This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject.(Inherited from DependencyObject.) |
![]() | Equals(Object^) | Determines whether a provided DependencyObject is equivalent to the current DependencyObject.(Inherited from DependencyObject.) |
![]() | Freeze() | |
![]() | GetAnimationBaseValue(DependencyProperty^) | Returns the non-animated value of the specified DependencyProperty.(Inherited from Animatable.) |
![]() | GetAsFrozen() | |
![]() | GetCurrentValueAsFrozen() | |
![]() | GetHashCode() | Gets a hash code for this DependencyObject.(Inherited from DependencyObject.) |
![]() | GetLocalValueEnumerator() | Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject. (Inherited from DependencyObject.) |
![]() | GetType() | |
![]() | GetValue(DependencyProperty^) | Returns the current effective value of a dependency property on this instance of a DependencyObject. (Inherited from DependencyObject.) |
![]() | InvalidateProperty(DependencyProperty^) | Re-evaluates the effective value for the specified dependency property(Inherited from DependencyObject.) |
![]() | ReadLocalValue(DependencyProperty^) | Returns the local value of a dependency property, if it exists. (Inherited from DependencyObject.) |
![]() | SetCurrentValue(DependencyProperty^, Object^) | Sets the value of a dependency property without changing its value source. (Inherited from DependencyObject.) |
![]() | SetValue(DependencyProperty^, Object^) | Sets the local value of a dependency property, specified by its dependency property identifier. (Inherited from DependencyObject.) |
![]() | SetValue(DependencyPropertyKey^, Object^) | Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property. (Inherited from DependencyObject.) |
![]() | ShouldSerializeProperty(DependencyProperty^) | Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property.(Inherited from DependencyObject.) |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
![]() | VerifyAccess() | Enforces that the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.) |
| Name | Description | |
|---|---|---|
![]() ![]() | DashesProperty | Identifies the Dashes dependency property. |
![]() ![]() | OffsetProperty | Identifies the Offset dependency property. |
The Dashes property of this class describes the length of alternating dashes and gaps. The values in the collection are in terms of multiples of the Thickness of the Pen. For example, an array of 1,2 specifies a dash of length (1 * Thickness) followed by a gap of length (2 * Thickness).
Note |
|---|
The actual length of the dash that is drawn depends on the style of DashCap that is added to each end of the dash. The default DashCap value for a Pen is Square. This causes an end cap that is one half the thickness of the line to be added onto each end of the pen stroke. (See PenLineCap for an example.) Therefore, if you specify an array of 0, 2 and a square DashCap, the actual dash length will be (0 * Thickness) + (2 * DashCap). |
If there are an odd number of values in the collection, the values are interpreted as if they had been repeated once to produce an even number of values. For example, a collection containing 2,3,5 is interpreted the same as a collection containing 2,3,5,2,3,5.
Negative values in the array are interpreted as their absolute value.
The following example shows how to use the DashStyle property of a Pen to create a dashed line under text.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <StackPanel Margin="20"> <TextBlock FontSize="36"> the lazy brown dog. <TextBlock.TextDecorations> <TextDecoration Location="Underline" PenThicknessUnit="FontRecommended"> <TextDecoration.Pen> <Pen Thickness="1.5" Brush="Red" > <!-- For the underline, create a dashed line with each dash twice the thickness of the Pen and each gap 8 times the thickness of the Pen. --> <Pen.DashStyle> <DashStyle Dashes="2,8"/> </Pen.DashStyle> </Pen> </TextDecoration.Pen> </TextDecoration> </TextBlock.TextDecorations> </TextBlock> </StackPanel> </Page>
The following illustration shows what the preceding example produces.

The following illustration shows examples of different dash styles applied to an underline.

Available since 3.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.






