示例#1
0
        private void UCDataColGrid_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            //TODO: check why we come here with non matching object
            if (!typeof(IObservableList).IsAssignableFrom(e.NewValue.GetType()))
            {
                return;                                                                  //avoid invalid cast exception
            }
            this.Dispatcher.Invoke(() =>
            {
                l = (IObservableList)e.NewValue;
                if (l.Count == 0)
                {
                    return;
                }

                // If it is input and we have only one row then no need to show the grid
                if (l[0].GetType() == typeof(ActInputValue) && l.Count == 1)
                {
                    ValueTextBox.Visibility  = System.Windows.Visibility.Visible;
                    MainDataGrid2.Visibility = System.Windows.Visibility.Collapsed;

                    Binding bd = new Binding("Value");
                    ValueTextBox.DataContext = l[0];
                    ValueTextBox.SetBinding(TextBox.TextProperty, bd);
                }
                else
                {
                    MainDataGrid2.Visibility = System.Windows.Visibility.Visible;
                    ValueTextBox.Visibility  = System.Windows.Visibility.Collapsed;
                    SetGridData();
                }
            });
        }
 private void RenameItem_Click(object sender, RoutedEventArgs e)
 {
     AddButton.Content  = "Ok";
     viewModel.EditMode = true;
     ValueTextBox.SetBinding(TextBox.TextProperty, new Binding("Value")
     {
         Source = viewModel.SelectedItem
     });
 }
示例#3
0
        public InputDialogView()
        {
            InitializeComponent();

            DataContext = this;

            ValueTextBox.SetBinding(TextBox.TextProperty, new Binding
            {
                Path = new PropertyPath(nameof(Text)),
                Mode = BindingMode.TwoWay,
                ValidatesOnExceptions = true,
                UpdateSourceTrigger   = UpdateSourceTrigger.PropertyChanged,
                Source = this
            });
        }
        private void EditItem_Click(object sender, RoutedEventArgs e)
        {
            if (ValueTextBox.Text.Trim().Length < 1)
            {
                MessageBox.Show("Введите значение в текстовое поле!");
                return;
            }

            viewModel.AddItem(ValueTextBox.Text);
            ValueTextBox.SetBinding(TextBox.TextProperty, new Binding("V")
            {
                Source = new object()
            });
            ValueTextBox.Text = "";
            AddButton.Content = "+";
        }