开发者

Clipping Path on an ImageBrush in Silverlight

Is there a way to put a clipping path on an ImageBrush in Silverlight (not an Image)? I don't see it available from Intellisense, but I'm wondering if there may be a 开发者_如何学编程way to do this.


Yet another unpopular "No" answer. The answer is: there is isn't a way to do this.

One possible work around if its vital to create such a brush might be to use a WriteableBitmap. Render an Image using the original source plus the Clip onto a WriteableBitmap then use it as the source to an ImageBrush.


Maybe this will help

I had a problem with an ImageBrush and a Border with a CornerRadius. I couldn't get the Image to fill/clip to fit. I resolved it by moving the ImageBrush to the content of the Border.

Here's the original with the problem:

<Border CornerRadius="0,0,4,4" BorderThickness="0">
    <Border.Background>
        <ImageBrush ImageSource="/SLTest;component/Resources/background_image.png" Opacity="1" Stretch="UniformToFill" />
    </Border.Background>
    <ListBox x:Name="lbiMesages" 
             Opacity="1" BorderThickness="0" 
             IsHitTestVisible="False" 
             ItemContainerStyle="{StaticResource ListBoxItemStyle1}"
             >

Here's the working version:

<ListBox x:Name="lbiMessages" 
     Opacity="1" BorderThickness="0" 
     IsHitTestVisible="False" 
     ItemContainerStyle="{StaticResource ListBoxItemStyle1}"
     >
     <ListBox.Template>
         <ControlTemplate>
             <Border CornerRadius="0,0,4,4" BorderThickness="0">
                 <Border.Background>
                     <ImageBrush ImageSource="/SLTest;component/Resources/background_image.png" Opacity="1" Stretch="UniformToFill" />
                 </Border.Background>
                 ...
              </Border>
         </ControlTemplate>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜