如何设置InkCanvas笔颜色的笔触不透明度?

时间:2018-05-16 16:12:00

标签: uwp inkcanvas

如何在UWP中设置墨迹笔划的不透明度?

1 个答案:

答案 0 :(得分:0)

您可以设置InkDrawingAttributesPencilProperties Class的不透明度属性以达到目标。

例如:

<InkCanvas x:Name="inkCanvas"></InkCanvas>
public MainPage()
{
    this.InitializeComponent();
    inkCanvas.InkPresenter.InputDeviceTypes =
        Windows.UI.Core.CoreInputDeviceTypes.Mouse |
        Windows.UI.Core.CoreInputDeviceTypes.Pen;

    InkDrawingAttributes pencilAttributes = InkDrawingAttributes.CreateForPencil();
    pencilAttributes.Color = Windows.UI.Colors.Red;
    pencilAttributes.Size = new Windows.Foundation.Size(3, 3);
    pencilAttributes.PencilProperties.Opacity = 0.5f;
    inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(pencilAttributes);
}