WPF:Strecht不更改其形式的路径

时间:2018-07-05 12:54:12

标签: wpf layout dynamic path size

我想创建自定义的shaepd标签来像在向导中一样象征进度。 但是当我将Strech-Property设置为Fill时,路径的天使就不同了。

example screenshot of my problem

XAML代码:

<Style x:Key="NavigationStepLabel" TargetType="{x:Type Label}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Label}">
                <Grid>
                    <Path Fill="{TemplateBinding Background}"  Data="M 0,0 h 50 l 5,20 l -5,20 h -50 l 5,-20 l -5,-20" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="2" Stretch="Fill"/>
                    <ContentPresenter Grid.Column="1" Margin="20,0" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
    <Setter Property="HorizontalAlignment" Value="Center"/>
    <Setter Property="VerticalAlignment" Value="Center"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="BorderBrush" Value="Gray"/>
</Style>

...

<Label Style="{StaticResource NavigationStepLabel}" Content="Start"> 
    <Label.Background>
         ...
    </Label.Background>
</Label>

有没有一种方法可以动态设置标签的路径大小,而不必使用不同的箭头?

0 个答案:

没有答案