Reputation: 301
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
}
}
How to update the selecteditem fname
TextBox when I click the listview in the UI without using {binding}
in the textbox?
FLOW
Upvotes: 1
Views: 114
Reputation: 5769
Declare an event handler for the SelectionChanged
event of your ListView
in the .xaml
:
<ListView Name="lview" ...
SelectionChanged="lview_SelectionChanged" />
Add the event handler to your .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;
}
Upvotes: 2