Binding to an objects member variable in a List
-
I am somewhat new to WPF and am loving the data binding, but it seems that I am still having a little bit of a rough time getting some things to work, one being this issue. I currently have an object that has a "Name" member variable as well as a few other member variables which I have made public accessors for. I then poulated a global List of these objects from a tab delimited file. I now have a listbox in my main window that I want to databind to the "Name" variable of each object listed in my List<> of these objects. In my XAML I currently have the below code where m_netObjArr is my global List which for each of my NetworkIDObjects I want to access their "Name" accessor.
<ListBox Height="Auto" Name="lbNetSelect" Width="Auto" MouseRightButtonDown="lbNetSelect_MouseRightButtonDown"
SelectionChanged="lbNetSelect_SelectionChanged" ItemsSource="{Binding ElementName=window1.m_netObjArr, Path=Name }"/>Any help or direction would be great! Thanks everyone!
-
I am somewhat new to WPF and am loving the data binding, but it seems that I am still having a little bit of a rough time getting some things to work, one being this issue. I currently have an object that has a "Name" member variable as well as a few other member variables which I have made public accessors for. I then poulated a global List of these objects from a tab delimited file. I now have a listbox in my main window that I want to databind to the "Name" variable of each object listed in my List<> of these objects. In my XAML I currently have the below code where m_netObjArr is my global List which for each of my NetworkIDObjects I want to access their "Name" accessor.
<ListBox Height="Auto" Name="lbNetSelect" Width="Auto" MouseRightButtonDown="lbNetSelect_MouseRightButtonDown"
SelectionChanged="lbNetSelect_SelectionChanged" ItemsSource="{Binding ElementName=window1.m_netObjArr, Path=Name }"/>Any help or direction would be great! Thanks everyone!
1. What is m_netObjArr? 2. If it is a member variable, then is it a public variable? Variable in a class has to bound like,
{Binding ElementName=window1, Path=m_netObjArr.Name}
or
{Binding ElementName=window1, Source=m_netObjArr, Path=Name}
Castle Rider
My: Website | Yahoo Group | Blog Spot
-
1. What is m_netObjArr? 2. If it is a member variable, then is it a public variable? Variable in a class has to bound like,
{Binding ElementName=window1, Path=m_netObjArr.Name}
or
{Binding ElementName=window1, Source=m_netObjArr, Path=Name}
Castle Rider
My: Website | Yahoo Group | Blog Spot
m_netObjArr is my public global List<> of my NetworkIDObjects: m_netObjArr NetworkIDObjects is an object containing a number of variables that I populate from an XML file. I want to populate my Listbox with the "Name" variable value for each of the NetworkIDObjects in my List and I do have a public accessor for Name. Thanks for your time!
-
1. What is m_netObjArr? 2. If it is a member variable, then is it a public variable? Variable in a class has to bound like,
{Binding ElementName=window1, Path=m_netObjArr.Name}
or
{Binding ElementName=window1, Source=m_netObjArr, Path=Name}
Castle Rider
My: Website | Yahoo Group | Blog Spot