【发布时间】:2020-05-19 21:13:45
【问题描述】:
我使用 inkscape 将 .svg 文件转换为 .xaml,生成的文件是画布。我将整个画布添加到文件 ImageResources.xaml 中的资源中:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas x:Key="xamltest" Name="svg2" Width="9354.3341" Height="5977.5567">
<Canvas.RenderTransform>
<TranslateTransform X="0" Y="0"/>
...
...
...
</Canvas>
</ResourceDictionary>
然后我将资源文件合并到资源字典中:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/AP_PlugIn;component/Resources/BrushLists.xaml" />
<ResourceDictionary Source="/AP_PlugIn;component/Resources/System/ConverterResources.xaml" />
<ResourceDictionary Source="/AP_PlugIn;component/Resources/ImageResources.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
最后,我尝试使用 ContentControl 在 Grid 中显示画布,但图像没有出现。有什么问题?我没有收到任何错误,我的项目正确启动
<Grid>
<ContentControl Content="{StaticResource xamltest}" Width="1253" Height="637" />
</Grid>
【问题讨论】:
-
您的图像为 9000x6000 像素,您的 ContentControl 大小为 1200x600 像素。我猜你图像的左上角 1200x600 像素是空的,这就是为什么什么都看不到。