enter image description here I'm using the GotFocus event on the WPF frontend which automatically assigns a value when I click on it. But my DateTime control will automatically select the cursor based on where I click. I want it to keep selecting the first one. This is my Xaml code
<dxe:DateEdit x:Name="_dateEdit"
EditValue="{Binding Time,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,RelativeSource={RelativeSource AncestorType=UserControl}}"
NullText="{Binding StrNullText,RelativeSource={RelativeSource AncestorType=UserControl}}"
Style="{Binding TimeStyle,RelativeSource={RelativeSource AncestorType=UserControl}}"
PopupOpening="DateEdit_PopupOpening"
GotFocus="DateEdit_GotFocus"
EditValueChanged="DateEdit_EditValueChanged">
<dxe:ButtonInfo x:Name="_dateEditButtonInfo" Tag="{Binding TimeTag,RelativeSource={RelativeSource AncestorType=UserControl}}" IsDefaultButton="True"/>
</dxe:DateEdit>
private void DateEdit_PopupOpening(object sender, DevExpress.Xpf.Editors.OpenPopupEventArgs e)
{
if (Time.HasValue)
{
return;
}
Time = DateTime.Now;
}
private void DateEdit_GotFocus(object sender, RoutedEventArgs e)
{
var dateEdit = sender as DateEdit;
if (Time.HasValue)
{
return;
}
Time = DateTime.Now;
Dispatcher.Invoke(() =>
{
//Attempted unsuccessful cases
Task.Delay(10000);
//dateEdit.Select(0, 2);
_dateEdit.SelectionStart = 0;
_dateEdit.SelectionLength = 0;
});
}
I tried the Select(0, 2) method and specified dateEdit.SelectionStart = 0; dateEdit.SelectionLength = 2; all failed The correct thing is that no matter where I click, it will be displayed like this enter image description here