using System; using System.Collections.Generic; using System.ComponentModel; 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.Navigation; using System.Windows.Shapes; namespace BWP.WinFormControl { public partial class NumberPad : INotifyPropertyChanged { private string _result; public string Result { get { return _result; } private set { _result = value; OnPropertyChanged("Result"); } } public NumberPad() { InitializeComponent(); DataContext = this; Result = string.Empty; } private void button_Click(object sender, RoutedEventArgs e) { var button = sender as Button; if (button != null) switch (button.CommandParameter.ToString()) { case "ESC": Close(); break; case "RETURN": DialogResult = true; break; case "BACK": if (Result.Length > 0) Result = Result.Remove(Result.Length - 1); break; default: Result += button.Content.ToString(); break; } } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } } } }