Unintended opacity mask change by child control
I want to make a canvas which has rounded border. I think I can implement it by OpacityMask. but it's a hard to me.
<Canvas Background="Red" ClipToBounds="T开发者_Python百科rue" x:Name="can">
<Canvas.OpacityMask>
<!--czc.png is opacity mask source which represents a rounded rectangle.-->
<ImageBrush ImageSource="/WpfApplication3;component/Images/czc.png"/>
</Canvas.OpacityMask>
<Image Source="/WpfApplication3;component/Images/1lvhuman.jpg" Margin="-129,56,192,46" Canvas.Left="193" Canvas.Top="25" Height="186" Width="153" />
</Canvas>
figure 1. is the Image in canvas that don't hanged in the Canvas's border. In the contrary, the Image of figure 2 hanged in left border of the Canvas. when hanged in there, OpacityMask was changed.
Why are you using Canvas? Can you just use a Border with a BorderRadius instead?
精彩评论