我正在尝试在WPF中使用精灵,并遇到了一些问题。整个精灵的大小为宽度=100高度=1754。第一张图像从0,0开始,所有图标都是32x32。到目前为止,我有以下代码,但图像根本没有渲染出来
<UserControl x:Class="Exemplify.Word.Addin.Presentation.ImageTestUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<BitmapImage x:Key="SpriteImage" UriSource="Assets/sprites2.png"/>
</UserControl.Resources>
<Grid>
<Button Name="Test">
<Image Height="32" Width="32" Source="{StaticResource SpriteImage}">
<Image.Clip>
<RectangleGeometry Rect="100, 1754, 32, 32"></RectangleGeometry>
</Image.Clip>
<Image.RenderTransform>
<TranslateTransform X="-100" Y="1754">
</TranslateTransform>
</Image.RenderTransform>
</Image>
</Button>
</Grid>