语言

DashStyle.Dashes 属性

定义

获取或设置此 DashStyle中的短划线和间隙的集合。

public:
 property System::Windows::Media::DoubleCollection ^ Dashes { System::Windows::Media::DoubleCollection ^ get(); void set(System::Windows::Media::DoubleCollection ^ value); };
public System.Windows.Media.DoubleCollection Dashes { get; set; }
member this.Dashes : System.Windows.Media.DoubleCollection with get, set
Public Property Dashes As DoubleCollection

属性值

短划线和间隙的集合。 默认值为空 DoubleCollection。

示例

以下示例演示如何使用 DashStyle a Pen 属性在文本下创建虚线。

<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>

注解

此集合描述交替短划线和间隙的长度。 集合中的值以集合的ThicknessPen倍数表示。 例如,一个数组12,指定长度短划线(1 * Thickness)后跟长度差距(2 * Thickness)。

注释

绘制的短划线的实际长度取决于添加到短划线的每个端的样式 DashCap 。 DashCap Pen默认值为 Square. 这会导致在笔划的每个端添加线条粗细的一半的结束帽。 (请参阅PenLineCap示例。)因此,如果指定数组02和正方形DashCap,则实际短划线长度将为 (0 * Thickness) + (2 * DashCap)。

如果集合中存在奇数值,则值将解释为重复一次以生成偶数值。 例如,包含 2,3的5集合被解释为与包含 2,3,5,2,,的35集合相同。

数组中的负值被解释为其绝对值。

Dependency 属性信息

项目 价值
标识符字段 DashesProperty
元数据属性设置为 true None

适用于