Line in style 的 TargetType 在 UWP 中不起作用 [英] The TargetType for Line in style doesn't work in UWP
本文介绍了Line in style 的 TargetType 在 UWP 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
<Grid>
<Grid.Resources>
<Style TargetType="Line">
<Setter Property="Stroke" Value="Black"></Setter>
<Setter Property="StrokeDashArray" Value="3"></Setter>
<Setter Property="StrokeThickness" Value="3"></Setter>
</Style>
</Grid.Resources>
<Line X1="20" X2="500" Y1="50" Y2="50"></Line>
<Line X1="20" X2="500" Y1="100" Y2="100"></Line>
<Line X1="20" X2="500" Y1="150" Y2="150"></Line>
</Grid>
您可以看到屏幕截图,样式中的 StrokeDashArray
属性值仅应用于第一行.为什么?
You could see the screenshoot, the StrokeDashArray
property value in the style only appled to the first line. Why?
推荐答案
我可以重现这个问题,但我不确定是什么导致了这种意外行为.我会向团队询问这个问题.作为一种解决方法,您可以使用 StaticResource 来共享 StrokeDashArray 的值.
I could reproduce this issue, but I'm not sure what caused this unexpected behavior. I'll ask the team about this issue. As a workaround, you could use StaticResource for sharing the value of StrokeDashArray.
<Grid>
<Grid.Resources>
<Style TargetType="Line">
<Setter Property="Stroke" Value="Black"></Setter>
<Setter Property="StrokeThickness" Value="3"></Setter>
</Style>
<x:String x:Key="strokeArray">3</x:String>
</Grid.Resources>
<Line X1="20" X2="500" Y1="50" Y2="50" StrokeDashArray="{StaticResource strokeArray}"></Line>
<Line X1="20" X2="500" Y1="100" Y2="100" StrokeDashArray="{StaticResource strokeArray}"></Line>
<Line X1="20" X2="500" Y1="150" Y2="150" StrokeDashArray="{StaticResource strokeArray}"></Line>
</Grid>
这篇关于Line in style 的 TargetType 在 UWP 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文