Can you render using a VisualBrush that has an offset?
I've got a 64x64 image that I'm using as the source of a VisaulBrush which I tile over the background of a control. However, based on some run-time logic, I want to change the origin of the visual brush. Not the tile size, just where the 'upper left' if you will is. In other words, think of it not as an offset into the tile itself, but rather an offset on where on the control the tiling begins.
However, asides from faking it by using the original image to manually render into a second image of the same size using a 2x2 pattern that starts at a specific negative offset (thus clipping that 2x2 to the size of the tile), then using that image as the so开发者_运维技巧urce for the actual tile brush, not sure how else I can achieve this. I'm surprised I haven't just seen any sort of TileOffset or something similar. May end up rolling my own subclass of the brush that does exactly that.
Unless someone else knows an easier way to do this... :)
well as it states here TileBrushs Viewport Property:
Gets or sets the position and dimensions of the base tile for a TileBrush
you can easily adjust the first two parameters of the ViewPort to offset the tile. eg:
<ImageBrush ImageSource="..."
Viewport="0,0,20,20" ViewportUnits="Absolute"
TileMode="Tile" />
if that was your base and you want to offset this 5px in x direction you do:
<ImageBrush ImageSource="..."
Viewport="5,0,20,20" ViewportUnits="Absolute"
TileMode="Tile" />
As TileBrush
is a base for ImageBrush
just as for VisualBrush
this applies equally to VisualBrush
.
精彩评论