WPF图片,DataGrid等实现圆角
程序员文章站
2022-06-20 18:27:03
<grid horizontalalignment="center" verticalalignment="center"> <grid.rowdefinitions> <rowdefinition height="auto"/> <rowdefinition/> </grid.rowdefinitions> <grid grid.row="1"> <grid rendertransformorigin="0.5,0.5"> <grid.rendertransform> <!--旋转--> <rotatetransform angle="{binding elementname=angle, path=value}"/> </grid.rendertransform> <!--圆角半径--> <border name="mask" cornerradius="{binding elementname=cornerradius, path=value}" background="white"/> <grid> <!--参考https://msdn.microsoft.com/zh-cn/library/bb979637(v=vs.95).aspx--> <grid.opacitymask> <visualbrush visual="{binding elementname=mask}"/> </grid.opacitymask> <!--这里可以放任何内容,均可实现圆角--> <image source="1104200s231-18.jpg"/> </grid> </grid> </grid> <!--控制按钮--> <grid grid.row="0" background="#a0ffffff"> <grid.columndefinitions> <columndefinition width="auto"/> <columndefinition/> <columndefinition width="auto"/> <columndefinition/> </grid.columndefinitions> <textblock grid.column="0" text="corner radius"/> <slider grid.column="1" name="cornerradius" minimum="0" maximum="400" margin="5,0,5,0"/> <textblock grid.column="2" text="angle" margin="5,0,0,0"/> <slider grid.column="3" name="angle" minimum="0" maximum="360" margin="5,0,0,0"/> </grid> </grid>