![](/img/trans.png)
[英]What framework to use for touch input tracking for Windows Store app using C#, XAML
[英]Issue re-using XAML paths for use within Windows 8 Store App
我正在尝试重新使用我在Windows 8商店应用程序中为图标制作的XAML <Path />
,但是当我尝试不止一次地重复使用它时,它从未显示过?
例如,两个初始实例都很好,我的Tick / Cross路径使用此XAML代码呈现:
<Path x:Name="TickGlyph" Style="{StaticResource TickGlyph}" Fill="#FF008500"
Grid.Column="1" Width="48" Height="48" Margin="24,0,4,0" />
<Path x:Name="CrossGlyph" Style="{StaticResource CrossGlyph}" Fill="#FF850000"
Grid.Column="1" Width="48" Height="48" Margin="24,0,4,0" />
一旦我用TickGlyph1
等名称重复该代码,我的后续路径只是空白,任何人都可以解释这里发生了什么,或者这对于Windows应用商店应用的XAML是一个奇怪的限制?
我的基础样式如下:
<Style x:Key="TickGlyph" TargetType="Path">
<Setter Property="Data" Value="F1 M 45.12,5.49L 21.255,40.8L 20.4525,40.8L 0,23.2875L 5.775,15.7875L 19.2525,27.3L 37.695,-1.90735e-006L 45.12,5.49 Z "/>
<Setter Property="Stretch" Value="Fill"></Setter>
</Style>
<Style x:Key="CrossGlyph" TargetType="Path">
<Setter Property="Data" Value="F1 M 0,32.505L 13.4025,19.1025L 0,5.69249L 5.67,-7.62939e-006L 19.08,13.41L 32.505,-7.62939e-006L 38.205,5.67L 24.7725,19.1025L 38.205,32.535L 32.505,38.205L 19.08,24.795L 5.67,38.205L 0,32.505 Z "/>
<Setter Property="Stretch" Value="Fill"></Setter>
</Style>
Style="{StaticResource TickGlyph}"
for Data="F1 M 45.12,5.49L 21.255,40.8L 20.4525,40.8L 0,23.2875L 5.775,15.7875L 19.2525,27.3L 37.695,-1.90735e-006L 45.12,5.49 Z "
我的所有路径都加载正常,为什么Style
属性不会荣誉?
:(
不确定,如果这是最好的解决方案,但几天前我已经使用过这种方法:
使用XAML定义从Path继承的自己的对象
<Path x:Class="MyProject.MyPath"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Data="F1M1568.35,1934.42L1551.46,1917.44 1551.46,1925.43C1517.67,1925.43 1515.02,1945.4 1515.02,
1949.39 1522.31,1933.42 1551.46,1941.4 1551.46,1941.4L1551.46,1949.39 1568.35,1934.42z"
Stretch="Uniform" Width="26" Height="26" UseLayoutRounding="False" RenderTransformOrigin="0.5,0.5">
</Path>
使用默认代码隐藏
public partial class MyPath
{
public MyPath()
{
InitializeComponent();
}
}
然后将其实例化到您想要的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.