我在页面上显示矢量图像时遇到了问题。
这应该可以,不是吗?
<ContentControl>
<ContentControl.Resources>
<ResourceDictionary Source="./Assets/vectorImage.xaml"></ResourceDictionary>
</ContentControl.Resources>
</ContentControl>
恐怕问题出在从Inkscape创建的位图转换成的xaml图像文件上。vectorImage.xaml相当大(136KB),所以我不会复制整个文件,但它的开头是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Stretch="Uniform">
<Canvas Name="svg2985" Width="126" Height="198">
<Canvas.Resources/>
...
编辑:
<ResourceDictionary Source="./Assets/vectorImage.xaml"></ResourceDictionary>
出现红色下划线和提示:期望 ResourceDictionary 的继承者。
当我运行应用程序时,我得到以下异常:
An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in app.exe but was not handled in user code
WinRT information: Failed to assign to property 'Windows.UI.Xaml.ResourceDictionary.Source'. [Line: 134 Position: 68]
编辑:
我忘记提到的一件事是这个项目是 Windows 应用商店应用程序。
ContentControl
的Resources
属性,但这本身并没有任何作用。你需要设置Content
属性才能显示任何内容,但我不确定如何让你的文件显示为内容。 - Dan Puzey