问题
I used the ActiveCustomDrying
to customize the ink, now I want to remove them InkStrokes
. StrokeContainer
is null
because of active the CustomDrying
, so I am unable to remove the InkStrokes
by using the DeleteSelected
method. Can anyone suggest me how to remove the InkStrokes
when using the CustomDrying
.
回答1:
During the custom drying, you will store the strokes in a custom List<InkStrokeContainer>
collection:
private void InkPresenter_StrokesCollected(InkPresenter sender, InkStrokesCollectedEventArgs args)
{
var strokes = _inkSynchronizer.BeginDry();
var container = new InkStrokeContainer();
container.AddStrokes(from item in strokes
select item.Clone());
_strokes.Add(container);
_inkSynchronizer.EndDry();
}
Now you can manipulate the InkStrokeContainer
instances manually (including calls to DeleteSelected
).
The documentation also states that when using ActiveCustomDrying
, erasing with InkToolbar
does not work automatically and you need to handle the pointer events manually
If your app overrides the default ink rendering behavior of the InkPresenter with a custom drying implementation, the rendered ink strokes are no longer available to the InkToolbar and the built-in erase commands of the InkToolbar do not work as expected. To provide erase functionality, you must handle all pointer events, perform hit-testing on each stroke, and override the built-in "Erase all ink" command.
If you want to implement the commands, you will need to observe the Checked
and Unchecked
events of the toolbar buttons and then handle the pointer events yourself. A complete tutorial how to do this is available on MSDN.
来源:https://stackoverflow.com/questions/48436425/how-to-remove-the-inkstroke-when-using-the-activecustomdrying-in-uwp