private void Update_Button(object sender, RoutedEventArgs e)
{
List<Employee> employees = new List<Employee>();
string fname = tb_firstname.Text;
var selectedEmployee = (Employee)lview.SelectedItem;
if (fname != null)
{
//update code
}
}
如果在不使用文本框中的fname
的情况下单击UI中的列表视图,如何更新selecteditem {binding}
TextBox?
FLOW
答案 0 :(得分:2)
为SelectionChanged
中ListView
的{{1}} .xaml
事件声明一个事件处理程序:
<ListView Name="lview" ...
SelectionChanged="lview_SelectionChanged" />
将事件处理程序添加到.xaml.cs
:
private void lview_SelectionChanged(object sender, System.Windows.RoutedEventArgs e)
{
// Assuming the property is Employee.FirstName
tb_firstname.Text = ((Employee)lview.SelectedItem).FirstName;
}