Interaction logic for CardListWindow.xaml
Пример #1
0
        private void OnButtonChooseCardClick(object sender, RoutedEventArgs e)
        {
            var    theSender    = sender as Button;
            string propertyName = ((theSender.Tag as TextBox).Tag as CardProperty).Name;

            var w = new CardListWindow(_thisCard.Model, propertyName);

            w.ShowDialog();

            if (w.Cancelled || w.SelectedCardNumber == "0")
            {
                return;
            }

            _thisCard.SetPropertyOrAttributValue(propertyName, w.SelectedCardNumber);

            try
            {
                _thisCard.Update();
                (theSender.Tag as TextBox).Text = string.Format(CultureInfo.InvariantCulture, "{0} - {1}", w.SelectedCardNumber,
                                                                w.SelectedCardName);
            }
            catch (Exception ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                MessageBox.Show(ex.Message);
            }
        }
        private void OnButtonChooseCardClick(object sender, RoutedEventArgs e)
        {
            var theSender = sender as Button;
            string propertyName = ((theSender.Tag as TextBox).Tag as CardProperty).Name;

            var w = new CardListWindow(_thisCard.Model, propertyName);
            w.ShowDialog();

            if (w.Cancelled || w.SelectedCardNumber == "0") return;

            _thisCard.SetPropertyOrAttributValue(propertyName, w.SelectedCardNumber);

            try
            {
                _thisCard.Update();
                (theSender.Tag as TextBox).Text = string.Format(CultureInfo.InvariantCulture, "{0} - {1}", w.SelectedCardNumber,
                                                                         w.SelectedCardName);
            }
            catch (Exception ex)
            {
                TraceLog.Exception(new StackFrame().GetMethod().Name, ex);
                MessageBox.Show(ex.Message);
            }
        }