public void Values_Initialize(IEnumerable <Tuple <string, Type, object> > values) { _elements.Clear(); _guiGrid.Children.Clear(); _guiGrid.RowDefinitions.Clear(); int idx = 0; foreach (var tuple in values) { _guiGrid.RowDefinitions.Add(new RowDefinition()); _guiGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(4) }); var label = new Label { Content = tuple.Item1 + ":" }; label.SetValue(Grid.RowProperty, idx * 2); _guiGrid.Children.Add(label); FrameworkElement fe; if (tuple.Item2 == typeof(double)) { var item = new Altaxo.Gui.Common.NumericDoubleTextBox(); fe = item; if (tuple.Item3 is double) { item.SelectedValue = (double)tuple.Item3; } } else { throw new NotImplementedException(); } fe.SetValue(Grid.ColumnProperty, 2); fe.SetValue(Grid.RowProperty, idx * 2); _guiGrid.Children.Add(fe); _elements.Add(new Tuple <Type, FrameworkElement>(tuple.Item2, fe)); ++idx; } // append another RowDefinition to ensure that the textboxes are not expanded vertically _guiGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(4, GridUnitType.Star) }); }
public void Values_Initialize(IEnumerable<Tuple<string, Type, object>> values) { _elements.Clear(); _guiGrid.Children.Clear(); _guiGrid.RowDefinitions.Clear(); int idx = 0; foreach (var tuple in values) { _guiGrid.RowDefinitions.Add(new RowDefinition()); _guiGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(4) }); var label = new Label { Content = tuple.Item1 + ":" }; label.SetValue(Grid.RowProperty, idx * 2); _guiGrid.Children.Add(label); FrameworkElement fe; if (tuple.Item2 == typeof(double)) { var item = new Altaxo.Gui.Common.NumericDoubleTextBox(); fe = item; if (tuple.Item3 is double) item.SelectedValue = (double)tuple.Item3; } else { throw new NotImplementedException(); } fe.SetValue(Grid.ColumnProperty, 2); fe.SetValue(Grid.RowProperty, idx * 2); _guiGrid.Children.Add(fe); _elements.Add(new Tuple<Type, FrameworkElement>(tuple.Item2, fe)); ++idx; } // append another RowDefinition to ensure that the textboxes are not expanded vertically _guiGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(4, GridUnitType.Star) }); }