这最终可能是一个非常愚蠢的问题,所以如果这很简单,请原谅我 - 我对 Silverlight 很陌生 :)
我想做的是将下面的 Image.RenderTransform 示例添加到我自己的项目中,但我的图像控件位于滚动查看器中,每当我尝试添加它时,我都会收到消息:
“在“图像”类型中找不到可附加属性“RenderTransform”
<Image MaxHeight="220" MaxWidth="200" Name="image1" Stretch="Uniform" Source="/FunWithMouseWheel;component/Images/sl4bloglogo.png" MouseWheel="image1_MouseWheel" Margin="531,346,124,199">
<Image.RenderTransform>
<ScaleTransform x:Name="imageScale"></ScaleTransform>
</Image.RenderTransform>
</Image>
我的 Xaml 文件:
<UserControl x:Class=Image_Viewer.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
<Grid x:Name="LayoutRoot"
Background="White" Height="717" Width="1086">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="713*" />
<ColumnDefinition Width="456*" />
</Grid.ColumnDefinitions>
<Button Content="Button" Height="35" HorizontalAlignment="Left" Margin="10,10,0,0" Name="btnGet" VerticalAlignment="Top" Width="115" Click="btnGet_Click" />
<Button Content="Rotate Left" Height="35" HorizontalAlignment="Left" Margin="132,10,0,0" Name="btnRotateLeft" VerticalAlignment="Top" Width="115" />
<ScrollViewer Grid.ColumnSpan="2" Height="520" HorizontalAlignment="Left" Margin="37,60,0,0" Name="scrollViewer" VerticalAlignment="Top" Width="840" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<ScrollViewer.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FF89D2FC" Offset="0" />
<GradientStop Color="#00009AFF" Offset="1" />
</LinearGradientBrush>
</ScrollViewer.Background>
<Image Height="465" Name="imgData" Stretch="Uniform" Width="767" MouseLeftButtonDown="imgData_MouseLeftButtonDown" MouseWheel="imgData_MouseWheel" />
<Image.RenderTransform></Image.RenderTransform> <----- causes the error
</ScrollViewer>
<Slider Height="248" HorizontalAlignment="Left" Margin="222,60,0,0" Name="slider" VerticalAlignment="Top" Width="39" Orientation="Vertical" Grid.Column="1" />
</Grid>
</UserControl>
感谢您的帮助!