I want to use an ImageBrush in a WPF element, and I want it to tile. But I want the image to line up with the bottom-left of the control, not the top-left. That is, instead of the top of the topmost tile being even with the top of the control, and a partial tile on the bottom end, I want it the other way around: the bottom of the bottom-most tile even with the bottom of the control, and a partial tile at the top. How can I do this?
Here's some XAML that repeats an image, but that anchors it to the control's top-left:
<Rectangle>
<Rectangle.Fill>
<ImageBrush ImageSource="C:\Temp\triangle.png"
Viewport="0 0 31 31"
ViewportUnits="Absolute"
TileMode="Tile"/>
</Rectangle.Fill>
</Rectangle>
Here's an illustration of what this does, and what I'm looking for (including what I want to happen as the element resizes):
(source: excastle.com)How can I anchor the tiled images to the bottom of the element instead of the top (and make sure they stay anchored at the bottom, even as the element resizes开发者_开发百科)?
The 'easiest' way is by calculating a other Viewport coordinates.
If the image is 20x20: Viewport="0 11 31 31" I could be wrong by a couple of units.
精彩评论