Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top