Category / Section
How to set Focus for DateTimeEdit?
1 min read
Cursor index position in DateTimeEdit when it have focus can behave based on the OnFocusBehavior property of DateTimeEdit. It can be changed as CursorOnFirstCharacter, CursorAtEnd, and Default.
The same has been explained in the following code snippet:
XAML:
//Code Explains how to set Focus Behavior in DateTimeEdit <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:syncfusion="http://schemas.syncfusion.com/wpf" x:Class="DateTimeEdit_FocusBehaviour.MainWindow" Title="MainWindow" Height="350" Width="525"> <Grid> <syncfusion:DateTimeEdit Name="DateTime" Width="150" Height="80" Text="DateTimeEdit" OnFocusBehavior="CursorOnFirstCharacter" /> </Grid> </Window>
C#:
//Code Explains how to set Focus Behavior in DateTimeEdit namespace DateTimeEdit_FocusBehaviour { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DateTime.OnFocusBehavior=OnFocusBehavior.CursorOnFirstCharacter; } } }
Output:
CursorOnFirstCharacter:
CursorAtEnd:
Default: