コード例 #1
0
        private void DatePicker_OnGotFocus(object sender, RoutedEventArgs e)
        {
            DatePicker @this       = sender as DatePicker;
            TextBox    partTextBox = @this?.FindVisualChildren <TextBox>().FirstOrDefault(x => x.Name == "PART_TextBox");

            if (partTextBox == null)
            {
                return;
            }
            Dispatcher.BeginInvoke((Action) delegate
            {
                Keyboard.Focus(partTextBox);
                partTextBox.SelectAll();
            }, DispatcherPriority.Render);
        }