i developing wpf application using wpf, have combobox selected item bound viewmodel , have datepicker. want disable datepicker in view depending on selecteditem of combobox.
the combo:
<combobox x:name="combobox2" grid.row="6" grid.column="1" selectedindex="0" itemssource="{binding path=duedateoptions}" selectedvalue="{binding urgent}">
the datepicker:
<datepicker x:name="datepicker1" grid.row="6" grid.column="2" selecteddate="{binding duedate, mode=twoway}"/>
how can achieve purpose, hope little help.
one way achieve is, adding property viewmodel , binding isenabled property of datepicker that. need set property inside setter of urgent property: (assuming have property named urgent in viewmodel):
class yourviewmodel { private bool allowpickdate; public bool allowpickdate { { return this.allowpickdate; } set { if (this.allowpickdate != value) { this.allowpickdate = value; this.onpropertychanged("allowpickdate"); } } } public urgenttype urgent { { .... } set { .... if (value == [whatever expect]) { this.allowpickdate = true; } else { this.allowpickdate = false; } } }
xaml:
<datepicker x:name="datepicker1" isenabled={binding allowpickdate} grid.row="6" grid.column="2" selecteddate="{binding duedate, mode=twoway}"/>
Comments
Post a Comment