c# - Binding a command to a checkbox for onclick inside a xamdatagrid in wpf not working -
i have checkbox inside xamdatagrid , follows :-
<igdp:unboundfield width="1*" label="{loctext props:resources.grouplist_sync}" bindingmode="twoway" bindingpath="issynchronise.value" converter="{staticresource booltoumdirectoryfilter}" converterparameter="enabled" tooltip="{loctext props:resources.grouplist_sync}"> <igdp:unboundfield.settings> <igdp:fieldsettings allowedit="true"> <igdp:fieldsettings.labelpresenterstyle > <style targettype="igdp:labelpresenter" basedon="{staticresource gmslabelstyle }"> <setter property="automationproperties.automationid" value="group_sync"></setter> </style> </igdp:fieldsettings.labelpresenterstyle> <igdp:fieldsettings.cellvaluepresenterstyle> <style targettype="{x:type igdp:cellvaluepresenter}"> <setter property="margin" value="2"></setter> <setter property="template"> <setter.value> <controltemplate targettype="igdp:cellvaluepresenter"> <checkbox name="chksynchronise" ischecked="{binding path=datacontext.dataitem.issynchronise.value, relativesource={ relativesource mode=templatedparent}}" horizontalalignment="center" command="{binding synchronisegroups,relativesource={relativesource mode=self}}" horizontalcontentalignment="left" > </checkbox> <!--<checkbox ischecked="{binding path=datacontext.dataitem.issynchronise.value, mode=twoway,updatesourcetrigger=propertychanged, relativesource={ relativesource mode=templatedparent}}" command="{binding synchronisegroups,relativesource={relativesource mode=self}}" horizontalalignment="center" horizontalcontentalignment="left" > </checkbox>--> </controltemplate> </setter.value> </setter> </style> </igdp:fieldsettings.cellvaluepresenterstyle> </igdp:fieldsettings> </igdp:unboundfield.settings> </igdp:unboundfield>
so, how should bind command checkbox in order work click , behaviour of checked , unchecked inside viewmodel? appreciated. in advance.
at first want add side note: since infragistics release 14.2 unbound field obsolete (look here).
for binding boolean xamdatagrid prefer using checkboxfield.
class:
public class yourclass : notificationobject { private bool _checkboxvalue; public bool checkboxvalue { { return this._checkboxvalue; } set { if (this._checkboxvalue != value) { this._checkboxvalue = value; // something: event, method, ... this.raisepropertychanged(nameof(this.checkboxvalue)); } } } }
xaml:
<igdp:fieldlayout> <igdp:checkboxfield bindingtype="usealternatebinding" name="checkerfield" label="yourcheckerfieldlabel" tooltip="yourtooltip" alternatebinding="{binding checkboxvalue, mode=twoway, updatesourcetrigger=propertychanged}" /> </igdp:fieldlayout>
Comments
Post a Comment