WPF DatePicker DisplayDate binding does not work inside DataGrid/DataTemplate/ControlTemplate -
it seems wpf datepicker's displaydate binding not work when datepiceker inside datagrid or datatemplate.
here sample code
<datagrid x:name="grid" autogeneratecolumns="false" isreadonly="true"> <datagrid.columns> <datagridtemplatecolumn header="startdate" minwidth="155"> <datagridtemplatecolumn.celltemplate> <datatemplate> <datepicker selecteddate="{binding path=startdate}" /> </datatemplate> </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> <datagridtemplatecolumn header="enddate" minwidth="155"> <datagridtemplatecolumn.celltemplate> <datatemplate> <datepicker selecteddate="{binding path=enddate}" displaydate="{binding path=startdate}"/> </datatemplate> </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> </datagrid.columns> </datagrid> public class model { public datetime? startdate { get; set; } public datetime? enddate { get; set; } }
display date stuck current date. no matter start date is. tried setting binding mode etc did not work. wrong?
note: although not matter initial binding, inotifypropertychanged implemented in original code.
https://connect.microsoft.com/visualstudio/feedback/details/1291078
<datepicker displaydate={binding path=displaydate} loaded="datepicker_loaded" />
and add code:
private void datepicker_loaded(object sender, routedeventargs e) { datepicker dp = sender datepicker; if (dp != null) { dp.clearvalue(datepicker.displaydateproperty); } }
Comments
Post a Comment