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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -