c# - Fill the outside of a rectangle -


i draw rectangle in wpf (by code) , fill outside of it.

here example :

enter image description here

the outside of rectangle grey (with low opacity), , fill of rectangle trasparent.

you may overlay image semi-transparent path element uses combinedgeometry combines 1 large outer rectangle inner rectangle:

<grid>     <image name="image" source="c:\users\public\pictures\sample pictures\koala.jpg"/>     <path fill="#aaffffff">         <path.data>             <combinedgeometry geometrycombinemode="xor">                 <combinedgeometry.geometry1>                     <rectanglegeometry rect="0,0,10000,10000"/>                 </combinedgeometry.geometry1>                 <combinedgeometry.geometry2>                     <rectanglegeometry x:name="transparentrect" rect="150,100,200,100"/>                 </combinedgeometry.geometry2>             </combinedgeometry>         </path.data>     </path> </grid> 

you programatically adjust rect property of transparentrect member needed.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -