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; namespace DyeingComputer.Windows { /// /// InputBox.xaml 的交互逻辑 /// public partial class InputBox : Window { public InputBox() { InitializeComponent(); this.DataContext = this; FocusManager.SetFocusedElement(Boxx, Boxx); } public string InputValue { get { return Boxx.Text; } set { this.Boxx.Text = value; } } public event EventHandler Accept; private void YES_Click(object sender, RoutedEventArgs e) { var input = Boxx.Text.TrimStart(); //去除字符串前空格 if (input.Length == 0) //字长度不等于0有效 { Boxx.Focus(); //聚焦元素 } else { if (Accept != null) { Accept(this, EventArgs.Empty); } this.Close(); //关闭窗口 } } private void NO_Click(object sender, RoutedEventArgs e) { this.Close(); //关闭窗口 } } }