c# - How may I access the the signature pad points using MVVM pattern? -
using xamarin.forms signaturepad control within xamarin.forms project using mvvm pattern, how may bind or should bind to, allow me access signature points?
i have following:
view:
<?xml version="1.0" encoding="utf-8" ?> <contentpage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:signature="clr-namespace:signaturepad.forms;assembly=signaturepad.forms" xmlns:local="clr-namespace:app12.viewmodels;assembly=app12" x:class="app12.views.signaturexamlview" bindingcontext="{staticresource viewmodel}"> <contentpage.resources> <resourcedictionary> <local:signaturexamlviewmodel x:key="viewmodel"/> </resourcedictionary> </contentpage.resources> <stacklayout> <signature:signaturepadview x:name="padview" heightrequest="135" widthrequest="600" backgroundcolor="white" captiontext="" captiontextcolor="black" cleartext="clear signature" cleartextcolor="red" prompttext="sign here" prompttextcolor="red" signaturelinecolor="black" strokecolor="black" strokewidth="2"/> <button text="get signature image"/> <button text="save signature" command="{binding savesignaturecommand}"/> </stacklayout> </contentpage>
viewmodel:
using signaturepad.forms; using system.threading.tasks; using xamarin.forms; namespace app12.viewmodels { public class signaturexamlviewmodel : baseviewmodel { private point[] padviewpoints; private signaturepadview signaturepadviewtemp; public signaturexamlviewmodel() { signaturepadviewtemp = new signaturepadview(); savesignaturecommand = new command(async () => await savesignature()); } async task savesignature() { var temp = padviewpoints; var temparray = padviewpoints; } public point[] padviewpoints { { return padviewpoints; } set { padviewpoints = value; } } public signaturepadview signaturepadviewtemp { { return signaturepadviewtemp; } set { signaturepadviewtemp = value; } } public command savesignaturecommand { get; private set; } } }
the viewmodel code isn't being used. it's trial , error code i've been trying work.
wiki
Comments
Post a Comment