作为StaticResources的XAML图像在Windows Universal应用程序中引发错误

时间:2015-04-19 19:52:08

标签: xaml winrt-xaml win-universal-app staticresource

我想在整个Windows通用应用程序中使用一些矢量图标。我已将它们添加到资源字典中,将字典添加到app.xml中的合并字典,并尝试使用页面中的资源。这些图像实际显示在编辑器预览窗口中,但在我尝试调试应用程序时抛出错误。

ManaSymbols.xaml

<?xml version="1.0" encoding="UTF-8"?>
<xaml:ResourceDictionary 
    xmlns:xaml="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Viewbox x:Key="BlueManaSymbol" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Stretch="Uniform">
        <Canvas Width="100" Height="100">
            <Canvas.RenderTransform>
                <TranslateTransform X="0" Y="0"/>
            </Canvas.RenderTransform>
            <Canvas>
                <Canvas>
                    <Ellipse Width="100" Height="100" Fill="#FFC1D7E9"/>
                </Canvas>
                <Path Fill="#FF0D0F0F">
                    <Path.Data>
                        M 68.91657 83.71021 C 58.968869 94.408441 39.101769 93.367284 30.985174 80.955583 23.700186 70.338629 25.060135 55.965661 30.782622 44.970201 37.43962 31.696018 47.119757 19.99635 58.53257 10.53421 c -1.779599 7.330526 -2.971221 15.369494 0.5678 22.406733 4.282692 9.098857 12.226705 16.065144 15.7407 25.557642 2.950311 8.612064 0.582748 18.823437 -5.9245 25.211625 z m -0.129 -27.362 c -0.82319 -2.47714 -5.460323 -8.506164 -4.125006 -2.813916 -0.362035 4.191263 -1.937779 8.124558 -3.178994 12.106916 -0.269255 7.254198 11.007675 4.685165 9.226 -1.795 -0.01849 -2.611632 -0.877381 -5.133602 -1.922 -7.498 z
                    </Path.Data>
                </Path>
            </Canvas>
        </Canvas>
    </Viewbox>
</xaml:ResourceDictionary>

的App.xaml

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Assets/ManaSymbols.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

Page.xaml

<ContentControl Content="{StaticResource BlueManaSymbol}" Grid.Row="0" Margin="70,0,0,0" Width="30" Height="30" />

调试时抛出错误:

A first chance exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in MagicStats.Windows.exe
WinRT information: Failed to assign to property 'Windows.UI.Xaml.Controls.ContentControl.Content'. [Line: 79 Position: 25]

错误消息似乎表明绑定失败,但它实际上在设计窗口中有效。任何想法都表示赞赏。

0 个答案:

没有答案