我知道这是一个老问题......但是有几种方法可以解决这个问题。希望这对谷歌搜索者有所帮助,我将分享两种方式。
首先,您可以简单地在 Canvas 周围放置一个 Viewbox(您从转换后的 .ai 文件中获得)。请注意,您可能必须使用 Stretch 和 alignment 属性来使其按您希望的方式运行……但很可能您会将 Stretch 设置为 UniformToFill 并将对齐属性设置为 Center:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="BackgroundSkin.MainWindow"
x:Name="Window"
Width="640"
Height="480"
>
<Grid x:Name="LayoutRoot">
<Viewbox
Stretch="UniformToFill"
HorizontalAlignment="Center"
VerticalAlignment="Center"
>
<!-- Replace the following Canvas with yours. -->
<Canvas Background="White"/>
</Viewbox>
</Grid>
</Window>
其次,如果您希望有更多可共享的东西(这样您可以将其用作多个 Windows 上的背景),您可以从该作品中创建一个画笔。有几种方法可以做到这一点。首先是简单地认识到您可以使用Expression Design 将.ai 文件转换为DrawingBrush(即Expression Design 可以通过两种主要方式导出:Canvas/Shape(s) 或ResourceDictionary/Brush(es))。
如果您没有用于重新导出的原始 .ai/.design 文件,您可以从画布上创建一个 VisualBrush(正如@Ugar Turan 建议的那样)。请注意,这次您可能不得不再次在 VisualBrush 上使用 Stretch 属性(和其他属性):
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="BackgroundSkin.MainWindow"
x:Name="Window"
Width="640"
Height="480"
Background="{DynamicResource backgroundBrush}"
>
<Window.Resources>
<!-- Replace the following Canvas with yours. -->
<Canvas x:Key="backgroundCanvas"/>
<VisualBrush
x:Key="backgroundBrush"
Visual="{DynamicResource backgroundCanvas}"
Stretch="UniformToFill"
/>
</Window.Resources>
</Window>