If I use the CellEditTemplate to show a custom view when editing - the view does not get auto focus when shown and the end user needs to tap inside so the view gets focus.
<telerik:DataGridTextColumn PropertyName="CountryName" HeaderText="Country">
<telerik:DataGridTextColumn.CellEditTemplate>
<DataTemplate>
<telerik:RadEntry Text="{Binding Item.CountryName}" />
</DataTemplate>
</telerik:DataGridTextColumn.CellEditTemplate>
</telerik:DataGridTextColumn>
Work-around:
Manually invoke the Focus() method and set the cursor position when the view gets loaded and when it changes its visibility:
<telerik:RadEntry Text="{Binding Item.CountryName}"
Loaded="RadEntry_Loaded"
PropertyChanged="RadEntry_PropertyChanged" />
private void RadEntry_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(View.IsVisible))
{
RadEntry entry = (RadEntry)sender;
if (entry.IsVisible)
{
FocusEntry(entry);
}
}
}
private void RadEntry_Loaded(object sender, EventArgs e)
{
FocusEntry((RadEntry)sender);
}
private static void FocusEntry(RadEntry entry)
{
entry.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(1), () =>
{
entry.Focus();
entry.CursorPosition = entry.Text?.Length ?? 0;
});
}