我有一系列矢量XAML文件(来自Icon Experience)。如何在另一个窗口中使用它们?我尝试将它们作为资源字典添加到app.xaml中,但是出现错误“查找资源字典时发生错误”
示例XAML向量
<Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Width="128" Height="128">
<Canvas Width="10240" Height="10240">
<Path Data="M6400 7527l0 -2330 -3620 3621c-125,124 -328,124 -453,0l-905 -905c-124,-125 -124,-328 0,-453l3621 -3620 -2329 0c-67,0 -123,-38 -148,-99 -26,-61 -12,-128 34,-174l1460 -1460c124,-124 276,-187 452,-187l3488 0c176,0 320,144 320,320l0 3488c0,176 -63,328 -187,452l-1460 1460c-46,46 -113,60 -174,34 -61,-25 -99,-81 -99,-147z" Fill="#252525"/>
</Canvas>
我试图将它们添加到app.xaml
<ResourceDictionary x:Name="arrowIE" Source="Assets/arrow_up_right/xaml"/>
答案 0 :(得分:1)
这样做:
创建资源字典(在解决方案资源管理器中右键单击项目节点,然后选择添加> 资源字典):
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DuplicateFinder.Views">
<PathGeometry x:Key="UpArrow" Figures="M6400 7527l0 -2330 -3620 3621c-125,124 -328,124 -453,0l-905 -905c-124,-125 -124,-328 0,-453l3621 -3620 -2329 0c-67,0 -123,-38 -148,-99 -26,-61 -12,-128 34,-174l1460 -1460c124,-124 276,-187 452,-187l3488 0c176,0 320,144 320,320l0 3488c0,176 -63,328 -187,452l-1460 1460c-46,46 -113,60 -174,34 -61,-25 -99,-81 -99,-147z" />
</ResourceDictionary>
在主窗口(或UserControl)中包含资源字典:
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Dictionary1.xaml" />
</ResourceDictionary.MergedDictionaries>
<!--Place other resources here-->
</ResourceDictionary>
</Window.Resources>
在Path对象中使用图标数据。使用ViewBox
使它们适合可用空间:
<Viewbox Stretch="Uniform">
<Path Data="{StaticResource UpArrow}" Fill="Black" Stroke="Black" />
</Viewbox>