public void ReplaceNewTextBox(string text) { textContent.Children.Remove(textBox); textBox = null; NumberTextBox number = new NumberTextBox(); number.HorizontalAlignment = HorizontalAlignment.Stretch; number.VerticalAlignment = VerticalAlignment.Stretch; textContent.Children.Add(number); textBox = number; textBox.Text = text; Panel.SetZIndex(textBox, -1); textBox.AllowDrop = true; textBox.Background = Brushes.Transparent; }
private void newTextbox(int col, PropertyInfo prop, object sourceObj, int indexInList) { var numBox = new NumberTextBox(); numBox.Background = Brushes.White; numBox.Tag = new listItem() { index = indexInList, property = prop, sourceObject = sourceObj }; numBox.Text = prop.GetValue(sourceObj).ToString(); numBox.AllowDrop = false; InputMethod.SetIsInputMethodEnabled(numBox, false); numBox.LostFocus += TextBox_Loaded; Grid.SetColumn(numBox, col * 2 + 2); Grid.SetRow(numBox, _grid.RowDefinitions.Count - 1); _grid.RowDefinitions[_grid.RowDefinitions.Count - 1].Height = new GridLength(30); numBox.Margin = new Thickness(0, 2, 0, 0); numBox.VerticalAlignment = VerticalAlignment.Center; _grid.Children.Add(numBox); }
private void TextBox_Loaded(object sender, RoutedEventArgs e) { NumberTextBox tb = sender as NumberTextBox; if (tb.Text == "") { return; } listItem item = tb.Tag as listItem; item.property.SetValue(item.sourceObject, Convert.ChangeType(tb.Text, item.property.PropertyType)); if (objectList.Count < item.index + 1) { objectList.Add(item.sourceObject); } else { objectList[item.index] = item.sourceObject; } }