【发布时间】:2016-11-11 09:42:35
【问题描述】:
我是 WPF 新手。
当我单击按钮时,将显示一个动态文本框。
每当文本框获得焦点时,它都会显示一个网格视图。
该网格视图包含一个值表。
当我输入一行时,它将绑定到文本框,但是当输入值后显示 gridview 时,它不会显示新值。
int count = 0;
private void button_Click(object sender, RoutedEventArgs e)
{
TextBox t = new TextBox();
t.MinHeight = 15;
t.Width = 100;
t.Height = 30;
t.Name = "txtPKSourceCode";
t.Text = "{Binding PurchaseOrder.PickupSrcCodeName, Mode=TwoWay}";
ColumnDefinition colDef1;
colDef1 = new ColumnDefinition();
mymy.ColumnDefinitions.Add(colDef1);
RowDefinition rowDef1;
rowDef1 = new RowDefinition();
mymy.RowDefinitions.Add(rowDef1);
++count;
mymy.Children.Add(t);
Grid.SetColumn(t, 0);
Grid.SetRow(t, count);
t.GotFocus += t_GotFocus;
}
private void t_GotFocus(object sender, RoutedEventArgs e)
{
button.Visibility = Visibility.Hidden;
SourceCodeDialog sourcedlg = new SourceCodeDialog("txtPKSourceCode");
sourcedlg.Owner = Window.GetWindow(this);
sourcedlg.POWindow = this;
var srcresult = sourcedlg.ShowDialog();
}
【问题讨论】: