0

How to set the opacity for ink stroke in the UWP?

James Z
  • 12,209
  • 10
  • 24
  • 44
Santhiya
  • 191
  • 2
  • 14

1 Answers1

0

You could set the opacity property of InkDrawingAttributesPencilProperties Class to achieve your target.

For example:

<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);
}
Xie Steven
  • 8,544
  • 1
  • 9
  • 23