In WPF app I have a ListView:
<ListView Height="100" Width="434" x:Name="lvItems" ItemsSource="{Binding ElementName=MainWindow, Path=ShowQuCollection}" >
<ListView.View>
<GridView>
<GridViewColumn Header="Date" Width="100" DisplayMemberBinding="{Binding Date}"/>
<GridViewColumn Header="Time" Width="100" DisplayMemberBinding="{Binding Time}"/>
<GridViewColumn Header="Description" Width="200" DisplayMemberBinding="{Binding Description}"/>
</GridView>
</ListView.View>
which is connected with ObservableCollection through databinding:
ObservableCollection<ShowsQu> _ShowQuCollection =
new ObservableCollection<ShowsQu>();
public ObservableCollection<ShowsQu> ShowQuCollection
{ get { return _ShowQuCollection; } }
public class ShowsQu
{
public string ShowCode { get; set; }
public DateTime Date { get; set; }
public TimeSpan Time { get; set; }
public string Description { get; set; }
}
This ObservableCollection placed in code-behind file of the same window, where ListView is (MainWindow). Everything works fine.
Now I add yet another ListView to different window and in this case databinding isn't working. This databinding piece of XAML I didn't change:
ItemsSource="{Binding ElementName=MainWindow, Path=ShowQuCollection}
How should I change this ListView databinding declaration (ListView in SecondWindow) in order it was connected with the ObservableCollection in the MainWindow?