Unable to hide the control in WPF using MVVM -
when selected values in combo box,i have hide control. have write code shown in below. please correct me made mistake in that.
view code:
<combobox x:name="cboshowrulewhere" height="20" width="200" itemssource="{binding source={staticresource listedview}, path=filterrules}" displaymemberpath="rulename" selectedvaluepath="ruleid" selectedvalue="{binding source={staticresource listedview}, path=selectedrulename, updatesourcetrigger=propertychanged, mode=twoway}" ></combobox> <combobox height="21" horizontalalignment="left" margin="6,4,0,0" x:name="cborulecondtion" visibility="{binding path=isbuttonvisible,converter={staticresource booltovisible}}" verticalalignment="top" width="212" /> viewmodel code:
private datatable m_selectedrulename; public datatable selectedrulename { { return m_selectedrulename; } set { m_selectedrulename = value; base.raisepropertychangedevent("selectedrulename"); } } private bool _isbuttonvisible; public bool isbuttonvisible { { return _isbuttonvisible; } set { _isbuttonvisible = value; base.raisepropertychangedevent("isbuttonvisible"); } } where have correct? please me asap. in advance..
there's not whole lot go on here. instance, setting isbuttonvisible based on rule criteria? here ideas:
1) don't create backing field isbuttonvisible. instead, have return correct analysis.
public bool isbuttonvisible { { return selectedrulename == "isvisiblerule"; } } 2) can fire notify propery changed event anywhere. in case, want isbuttonvisible binding reevaluated every time selectedrulename changes:
private datatable m_selectedrulename; public datatable selectedrulename { { return m_selectedrulename; } set { m_selectedrulename = value; base.raisepropertychangedevent("selectedrulename"); base.raisepropertychangedevent("isbuttonvisible"); } } 3) selectedrulename datatable? seem odd me because indicates multiple rows. longer post, avoid datatable altogether , change combobox item source observablecollection. "selectedrulename" of type t (not datatable).
4) along same lines, have found greater success using selecteditem instead of selectedvalue.
i hope of helps.
Comments
Post a Comment