Binding a DataSet to a ListBox in a WPF XBAP application
-
Can anyone help me in letting me know how to bind a dataset to a listbox in a WPF XBAP application. The dataset contains a table with two columns.
-----Have A Nice Day-----
-
You bind the DataContext of the ListBox to the DataSet and set the ItemsSouce binding with Path as the tablename OR you directly bind the table to the ItemsSource property.
-
Hi, Can you please provide me the code to set the ItemSource binding to the path as suggested by you.
-----Have A Nice Day-----
1. Setting the DataSet to the DataContext and binding the ItemsSource using binding Path. e.g., In code setting the DataContext, yourListBox.DataContext= yourDataSet; in XAML setting ItemsSource binding, 2. Setting the DataTable directly to the ListBox's ItemsSource, yourListBox.ItemsSource = yourDataSet.Tables["YourTableName"];
-
You bind the DataContext of the ListBox to the DataSet and set the ItemsSouce binding with Path as the tablename OR you directly bind the table to the ItemsSource property.
-
Can anyone help me in letting me know how to bind a dataset to a listbox in a WPF XBAP application. The dataset contains a table with two columns.
-----Have A Nice Day-----
Databinding - if you read 100 examples you will find 100 ways to do that databinding - pick one at random and give it a try - repeat until something works. That's what I do then I scrap the app anyway because WPF is always too slow and I am not a designer so everything looks rubbish.