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.
Asked
Active
Viewed 575 times
2 Answers
2
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.

AnthonyWJones
- 187,081
- 35
- 232
- 306
-
Argh...man I'm finding SL to be limited. I was hoping there would be a way to do this. – Todd Main Jul 08 '10 at 08:33
-
@Otaku: Limited in comparison to what? Silverlight needs to deliver a plugin and a set of libraries with a reasonable internet friendly foot print. There are also performance issues to consider, Silverlight cannot assume the same stance with regard to CPU usage that an Installed Windows app might take. On top that Silverlight apps need to work on both Windows and Mac unmodified. Altogether some heavy duty compromises would be necessary. – AnthonyWJones Jul 08 '10 at 08:47
-
Limited to itself. If an `
` can have a clipping path, I fail to see why an ` ` can't have one. If it is something net new like making a Rich Text Box (` an RTB that was actually any good `), I could understand, but clipping path already exists for an extremely similar component. – Todd Main Jul 08 '10 at 08:54
1
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>

pfa
- 125
- 17