如何将Image.RenderTransform标记添加到Silverlight中scrollViewer中的图像

时间:2013-06-18 16:37:04

标签: xml silverlight-4.0

这可能最终成为一个非常愚蠢的问题所以请原谅我,如果这很简单 - 我对银光很新:)

我想要做的是将下面的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>

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

修正了它 - 最终很简单!

问题是Image标签在行中关闭了:

 <Image Height="465" Name="imgData" Stretch="Uniform" Width="767" MouseLeftButtonDown="imgData_MouseLeftButtonDown" MouseWheel="imgData_MouseWheel" />

所以我只是删除了结束标记/并插入了Image.RenderTransform标记和一个额外的结束标记:

    <Image Height="465" Name="imgData" Stretch="Uniform" Width="767" MouseLeftButtonDown="imgData_MouseLeftButtonDown" MouseWheel="imgData_MouseWheel">
        <Image.RenderTransform>
            <RotateTransform Angle="0" />
        </Image.RenderTransform>
    </Image>