WPFのInkCanvas作为蒙版透明笔迹不透明

时间:2022-08-06 19:39:15

本人最近利用inkcavas做一个蒙版的功能,结果发现笔迹稀释了,经过一番查找发现:应该讲inkcavas的背景设置为白色,然后透明,而不是将整个控件透明,具体代码:

<InkCanvas Name="inkContent" Grid.RowSpan="2"
                   UseCustomCursor="True"
                   Cursor="{Binding CurrentCursor,ElementName=winWhite,Mode=OneWay}"
                   EditingModeInverted="Ink" 
                   EditingMode="{Binding CurrentEditMode,ElementName=winWhite,Mode=OneWay}"
                   DefaultDrawingAttributes="{Binding CurrentPen,ElementName=winWhite,Mode=OneWay}"
                   Loaded="inkContent_Loaded" >
            <InkCanvas.Background>
                <SolidColorBrush Color="White" Opacity="0.01" />
            </InkCanvas.Background>
        </InkCanvas>