答案 0 :(得分:1)
很抱歉迟到的回复。以下是一些可以帮助您的示例代码!
XAML:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<InkCanvas x:Name="testCanvas"/>
</Grid>
背后的代码
public MainPage()
{
this.InitializeComponent();
testCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse |
Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;
testCanvas.InkPresenter.StrokesCollected += InkPresenter_StrokesCollected;
}
private bool _strokeManipulating;
private void InkPresenter_StrokesCollected(InkPresenter sender, InkStrokesCollectedEventArgs args)
{
var strokes = args.Strokes;
if (!_strokeManipulating)
{
_strokeManipulating = true;
foreach (var s in strokes)
{
var n = s.Clone();
//pass the required x,y translation
var t = System.Numerics.Matrix3x2.CreateTranslation(5, 0);
n.PointTransform = t;
testCanvas.InkPresenter.StrokeContainer.AddStroke(n);
}
_strokeManipulating = false;
}
}