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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -