Example #1
0
        private void FillItems()
        {
            _guiItemStack.Children.Clear();

            for (int i = 0; i < _dataSource.Count; ++i)
            {
                var sp = new DockPanel {
                    HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch
                };
                var ta = new Button()
                {
                    Content = "+", Margin = new Thickness(0, -8, 4, 8), Tag = i
                };
                var tb = new QuantityWithUnitTextBox {
                    UnitEnvironment = Environment, SelectedQuantity = _dataSource[i], Tag = i, HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch
                };
                var tc = new Button {
                    Content = "Del", Tag = i, Margin = new Thickness(4, 0, 0, 0)
                };
                tb.SelectedQuantityChanged += EhSelectedQuantityChanged;
                ta.Click += EhAddRow;
                tc.Click += EhDelRow;

                ta.SetValue(DockPanel.DockProperty, Dock.Left);
                sp.Children.Add(ta);

                tc.SetValue(DockPanel.DockProperty, Dock.Right);
                sp.Children.Add(tc);

                sp.Children.Add(tb);

                _guiItemStack.Children.Add(sp);
            }

            var sp1 = new StackPanel {
                Orientation = Orientation.Horizontal
            };
            var ta1 = new Button()
            {
                Content = "+", Margin = new Thickness(0, -8, 0, 8), Tag = _dataSource.Count
            };

            ta1.Click += EhAddRow;
            sp1.Children.Add(ta1);

            _guiItemStack.Children.Add(sp1);
        }
		private void FillItems()
		{
			_guiItemStack.Children.Clear();

			for (int i = 0; i < _dataSource.Count; ++i)
			{
				var sp = new DockPanel { HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch };
				var ta = new Button() { Content = "+", Margin = new Thickness(0, -8, 4, 8), Tag = i };
				var tb = new QuantityWithUnitTextBox { UnitEnvironment = Environment, SelectedQuantity = _dataSource[i], Tag = i, HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch };
				var tc = new Button { Content = "Del", Tag = i, Margin = new Thickness(4, 0, 0, 0) };
				tb.SelectedQuantityChanged += EhSelectedQuantityChanged;
				ta.Click += EhAddRow;
				tc.Click += EhDelRow;

				ta.SetValue(DockPanel.DockProperty, Dock.Left);
				sp.Children.Add(ta);

				tc.SetValue(DockPanel.DockProperty, Dock.Right);
				sp.Children.Add(tc);

				sp.Children.Add(tb);

				_guiItemStack.Children.Add(sp);
			}

			var sp1 = new StackPanel { Orientation = Orientation.Horizontal };
			var ta1 = new Button() { Content = "+", Margin = new Thickness(0, -8, 0, 8), Tag = _dataSource.Count };
			ta1.Click += EhAddRow;
			sp1.Children.Add(ta1);

			_guiItemStack.Children.Add(sp1);
		}