如何在路径中将Translate Transform设置为ImageBrush?

时间:2010-11-13 10:47:47

标签: c# wpf silverlight expression-blend

我有以下简单路径。但每次在Expression Blend中我尝试将转换变换设置为其图像画笔时图像消失。理想情况下,填充应该是无。如果可能的话,我需要在画笔中动态设置图像的x和y。如果你在C#中做到这一点也会很好。或者我错了,这是不能做的?

<Path Data="M0.5,0.5 L99.5,0.5 L99.5,439.5 L0.5,439.5 z" Fill="#BFF31313" Height="440" Canvas.Left="192" Stretch="Fill" Stroke="Black" Canvas.Top="176" Width="100" Visibility="Collapsed">
    <Path.Fill>
        <ImageBrush ImageSource="4x4.png" Stretch="None"/>
    </Path.Fill>
</Path>

1 个答案:

答案 0 :(得分:1)

这样的东西?

<Path Data="M0.5,0.5 L99.5,0.5 L99.5,439.5 L0.5,439.5 z" Fill="#BFF31313" Height="440" Canvas.Left="192" Stretch="Fill" Stroke="Black" Canvas.Top="176" Width="100" Visibility="Collapsed">
    <Path.Fill>
        <ImageBrush ImageSource="4x4.png" Stretch="None">
            <ImageBrush.Transform>
                <TranslateTransform X="10" Y="10"/>
            </ImageBrush.Transform>
        </ImageBrush>
    </Path.Fill>
</Path>