wpf - How to receive the InkCanvas.StrokeCollected event in the view model -
in using mvvm pattern, have custom inkcanvas with:
protected override void onstrokecollected(inkcanvasstrokecollectedeventargs e) { customstroke newstroke = new customstroke(e.stroke.styluspoints, e.stroke.drawingattributes); this.strokes.remove(e.stroke); this.strokes.add(newstroke); inkcanvasstrokecollectedeventargs enew = new inkcanvasstrokecollectedeventargs(newstroke); // raises system.windows.controls.inkcanvas.strokecollected event. base.onstrokecollected(enew); }
how view model receive inkcanvas.strokecollected event?
i can not bind xaml strokes strokecollection.collectionchanged event called 3 times custom inkcanvas.
any appreciated.
try this
public window3() { initializecomponent(); var vm=new viewmodel(); this.datacontext = vm; canvas.strokecollected += vm.onstrokecollected; }
viewmodel
public class viewmodel { public void onstrokecollected(object sender, inkcanvasstrokecollectedeventargs e) { } }
edit
if want without codebehind see article eventtrigger
Comments
Post a Comment