wpf - How to make clipping geometry scale with the target? -


in following example whenever grid size changed, clipping region size remains expressed in absolute coordinates.

<grid clip="m10,10 l10,150 l150,150 l150,10 z">     <rectangle fill="red"/> </grid> 

is possible somehow clip region such clipping geometry scaled along clipped object?

code behind solutions not accepted, because used in control template. also, region in example simple shape clarity sake. actual used region complex , asymmetric shape.

edit:

it looks have more specific. snipped part of custom control template progressbar. when scaling outer grid, part_indicator rectangle not scale clipping region. correct composition when grid sized 200x200.

<grid>     <path name="part_track"            data="m100,0 a100,100 0 1 0 100,200 a100,100 0 1 0 100,0 z"           fill="aliceblue" stretch="fill"/>      <rectangle clip="m100,0 a100,100 0 1 0 100,200 a100,100 0 1 0 100,0 z"                stretch="fill"                name="part_indicator" fill="red"                 height="100" verticalalignment="top"/>      <path name="border" data="m100,0 a100,100 0 1 0 100,200 a100,100 0 1 0 100,0 z"           stretch="fill" strokethickness="3" stroke="black"/> </grid> 

update: rick provided excellent suggestion, though took time me understand how use it. here final code.

<viewbox stretchdirection="both" stretch="fill" >     <grid>         <path name="part_track"                data="m100,0 a100,100 0 1 0 100,200 a100,100 0 1 0 100,0 z"               fill="aliceblue" stretch="fill"/>          <border clip="m100,0 a100,100 0 1 0 100,200 a100,100 0 1 0 100,0 z"                 height="200" verticalalignment="bottom">             <rectangle name="part_indicator" fill="red" verticalalignment="bottom"                         height="40"/>         </border>          <path name="border"               data="m100,0 a100,100 0 1 0 100,200 a100,100 0 1 0 100,0 z"               strokethickness="3"               stretch="fill" stroke="black"/>     </grid> </viewbox> 

put grid inside of viewbox , change size of viewbox instead of grid.

<viewbox>     <grid clip="m10,10 l10,150 l150,150 l150,10 z" width="200" height="200">         <rectangle fill="red"/>     </grid> </viewbox> 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -