I am new in wpf
I am trying to bind listbox from datagrid the code is like this
DataGrid dataGrid = control as DataGrid;
Columnslst.ItemsSource = dataGrid.Columns;
Columnslst.DisplayMemberPath = "Header";
now i wont to bind text box from the Columnslst listbox in xaml
<TextBox Name="txtGridHeader" Margin="2" Text="{Binding ElementName=Columnslst, Path=SelectedItem.content}" ></TextBox>
but it does not work
why ???
what can i do
According to the c# code, each item in the DataSource if of
DataGridColumntype and one of its properties isHeader, just like you’ve set inDisplayMemberPath.In the
SelectedItemyou should have direct access to one of those objects (if any of them is selected), so so it’s still ofDataGridColumntype. Just try to use this line in xaml:Let me know if it worked for you.