using Muchinfo.MTPClient.Data.Model.Delivery; using Muchinfo.MTPClient.Delivery.ViewModels; using System.Windows; using System.Windows.Input; using Xceed.Wpf.Toolkit; namespace Muchinfo.MTPClient.Delivery.Views { /// /// Description for NDeliveryOrderView. /// public partial class NDeliveryOrderView : Window { /// /// Initializes a new instance of the NDeliveryOrderView class. /// public NDeliveryOrderView() { InitializeComponent(); } public NDeliveryOrderView(DeliveryOrderMessage parameter) { InitializeComponent(); this.DataContext = new NDeliveryOrderViewModel(parameter); } private void SelectQty_KeyDown(object sender, KeyEventArgs e) { var txtInput = (DecimalUpDown)sender; if ((e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9) || (e.Key >= Key.D0 && e.Key <= Key.D9)) { e.Handled = false; } else if ((e.Key == Key.Decimal || e.Key == Key.OemPeriod)) { e.Handled = false; } else { e.Handled = true; } if (txtInput.Text!=null && txtInput.Text.Contains(".") && txtInput.Text.Length >= 8) { e.Handled = true; } else if (txtInput.Text!=null && !txtInput.Text.Contains(".") && txtInput.Text.Length >= 6) { e.Handled = true; } if (!string.IsNullOrEmpty(txtInput.Text)) { var current = decimal.Parse(txtInput.Text); if (current > txtInput.Maximum) { txtInput.Text = txtInput.Maximum.ToString(); } } } private void DecimalUpDown_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { var txtInput = (DecimalUpDown)sender; if (txtInput.Text.Length >= 6) { e.Handled = true; } else { e.Handled = false; } } } }