adm*_*tDK 5 xaml win-universal-app
这是微不足道的事情,但它不起作用.
我有这样的东西(它在自己的文件夹中)
<ResourceDictionary>
<Path x:Key="Test"
Stroke="Black"
Fill="Gray"
Data="M 10,100 C 10,300 300,-200 300,100" />
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
现在我想用它
<Page>
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergeDictionaries>
<ResourceDictionary Source="MyFolder/MyResourceDictionary.xaml/>
</ResourceDictionary.MergeDictionaries>
</ResourceDictionary>
</Page.Resources>
<ContentPresenter Content="{StaticResource Test}"/>
<Page/>
Run Code Online (Sandbox Code Playgroud)
这会引发异常,但我不明白为什么.在wpf中完全相同的场景工作正常.
那这个解决方案呢?
声明你的 GeometryData
<x:String x:Key="TestPathGeomerty">M 10,100 C 10,300 300,-200 300,100</x:String>
Run Code Online (Sandbox Code Playgroud)
并Path改用ContentPresenter
<Path Data="{StaticResource TestPathGeomerty}"
Fill="Red"/>
Run Code Online (Sandbox Code Playgroud)
Path.Data 属性是类型Geometry,因此将其定义为 aGeometry而不是 astring
<Geometry x:Key="TestPathGeomerty">M 10,100 C 10,300 300,-200 300,100</Geometry>
<Path Data="{StaticResource TestPathGeomerty}"
Fill="Red"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2081 次 |
| 最近记录: |