Bind Datepicker

Nov 17, 2008 at 3:25 PM
I have following code:



<dg:DataGridTemplateColumn Header="Expense Date" MinWidth="100">

            <dg:DatePicker Name="dtExpenseDate" SelectedDate="{Binding Path=ExpenseDate}" SelectedDateFormat
="Short" />




    <dg:DataGridTemplateColumn.CellTemplate >
            <TextBlock Text="{Binding ExpenseDate

----- End Of Code

The data is displayed using a datatable. It displays the date from the datatable. But, when I change the date using the datepicker. It does not retian the selected date.

How do I bind the CellTemplate to display the date selected using datepicker?


Nov 19, 2008 at 7:23 PM
Edited Nov 19, 2008 at 7:29 PM
Thanks for finding this issue, J12 :-)  The following workaround should help you out:

<dg:DataGridTemplateColumn Header="Expense Date">



            <dg:DatePicker Name="dtExpenseDate" 
="{Binding Path=ExpenseDate, Mode=TwoWay}" />     


dg:DataGridTemplateColumn.CellTemplate >

        <DataTemplate >

            <TextBlock Text="{Binding ExpenseDate}"/>


    </dg:DataGridTemplateColumn.CellTemplate >


The difference here is the explicit use of TwoWay Binding with SelectedDate.

-Eric Fabricant, MSFT
Nov 20, 2008 at 2:08 PM
Thanks Eric,

Should have thought myself :).