48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
using System.Windows.Threading;
|
|
|
|
namespace MainShell.Recipe.View
|
|
{
|
|
/// <summary>
|
|
/// RecipeNameWindow.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class RecipeNameWindow : Window
|
|
{
|
|
public RecipeNameWindow()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (e.ChangedButton == MouseButton.Left)
|
|
{
|
|
this.DragMove();
|
|
}
|
|
}
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
// 使用 Dispatcher 确保控件已可交互,然后设置键盘焦点并全选文本
|
|
Dispatcher.BeginInvoke(new Action(() =>
|
|
{
|
|
RecipeNameTextBox.Focus();
|
|
Keyboard.Focus(RecipeNameTextBox);
|
|
RecipeNameTextBox.SelectAll();
|
|
}), DispatcherPriority.Input);
|
|
}
|
|
}
|
|
}
|