I have a datagrid and making one of its column as DateTemplate to showing Datepicker in it by using following xaml:
<DataTemplate x:Key="dtDateTime"><my:DatePicker Style="{StaticResource dpWhiteStyle}" x:Name="dpGridDate" FontSize="8" Height="18" Initialized="dpGridDate_Initialized" ></my:DatePicker></DataTemplate>
Now I need to set focus on DatePicker of a particular cell programatically. I used the following code:
DataGridCell cellDueDate = GetCell(UCGridDetail.dataGrid1, 0, 1); cellDueDate.Focus();
but this will set focus on the cell instead of datepicker control.
I also tried this code:
DataGridCell cellDueDate = GenFunc.GetCell(UCGridDetail.dataGrid1, 0, 1); cellDueDate.Focus(); DatePicker dtp = cellDueDate.Content as DatePicker; dtp.Focus();
But this will cause an error and doesn't work.
Is there a way to get datepicker from a cell?