简体   繁体   English

子控件意外更改不透明蒙版

[英]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. 我想我可以通过OpacityMask实现它。 but it's a hard to me. 但这对我来说很难。

<Canvas Background="Red" ClipToBounds="True" 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. 图1.是画布中未悬挂在画布边框中的图像。 In the contrary, the Image of figure 2 hanged in left border of the Canvas. 相反,图2的图像挂在画布的左边界。 when hanged in there, OpacityMask was changed. 挂在那里时,OpacityMask发生了变化。

Why are you using Canvas? 为什么要使用Canvas? Can you just use a Border with a BorderRadius instead? 您可以仅使用带有BorderRadius的Border吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM