Hi Guys, I have another question this time regarding Databinding.
Brief Project Description:
I have a ListBox in Window1.xaml that is displaying data from a SQL Database. More specifically, the Database contains three fields, "Name", "Address" and "Phone Number" and the ListBox is displaying only the "Name" field.
I have three Labels in UserControl1.xaml that i would like to display the "Name", "Address" and "Phone Number" of the selected item in the Window1 Lisbox.
Question:
Is it possible to use Databinding to get information from a field in another window?
UserControl1.xaml Code: (this code works when the label is in the same window but not when the Label is in the UserControl)
<Label x:Name="nameLabel"
Content="{Binding ElementName=listbox, Path=SelectedItem.Name}"/>
Window1.xaml Code:
<Window.Resource>
<DataTemplate x:Key="listboxTemplate">
<TextBlock Text="{Binding Path=Name}"/>
</DataTemplate>
</Window.Resources>
<Grid>
<ListBox x:Name="listbox" ItemTemplate="{StaticResource listboxTemplate}"/>
</Grid>
var query = from s in dc.People
orderby s.Name
select s;
listbox.ItemsSource = query.ToList();
Thanks in advance for your help,
Alex