Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How can get DatePicker from DataTemplate Column of dataGrid?

$
0
0

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?




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>