C# 将DataGrid绑定到ListView

C# 将DataGrid绑定到ListView,c#,wpf,listview,binding,datagrid,C#,Wpf,Listview,Binding,Datagrid,在WPF中,我想加载一个Excel文件,表格的第一列包含日期,其他列包含一些数据。我想将“xls”分成几个日期值数据集合,算法非常简单,已经完成了,但是: 现在,我有 public class XYPoint: INotifyPropertyChanged 在所有实现中。然后 public class XYManager { public ObservableCollection<XYPoint> XYPoints {get;set} public string SeriesNam

在WPF中,我想加载一个Excel文件,表格的第一列包含日期,其他列包含一些数据。我想将“xls”分成几个日期值数据集合,算法非常简单,已经完成了,但是: 现在,我有

public class XYPoint: INotifyPropertyChanged
在所有实现中。然后

public class XYManager
{
public ObservableCollection<XYPoint> XYPoints {get;set}
public string SeriesName{get;private set;}
}
XAML的相应部分:


    <ListView x:Name="lstTables" ItemsSource="{Binding SeriesName}" SelectedItem="{Binding XYPoints}"/>
                        <DataGrid x:Name="dgImported" Grid.Column="1" ItemsSource="{Binding XYPoints}"/>

我想要的是,当用户更改ListView中的选择时,Datagrid应该从相应的XYManager自动更新

提前谢谢
Jan

在XYManager类中设置XYPoints集合时,需要引发属性更改事件。至少从我看到的情况来看,这可能是问题所在。嗨,我试图更好地指定我的问题:我需要执行以下操作:
private void lstTables\u SelectionChanged(object sender,selectionchangedventargs e){if(lstTables.SelectedIndex>=0){dgImported.ItemsSource=\u dm.Data[lstTables.SelectedIndex].XYPoints;}}
使用bindings我认为这会起作用。但是,如果包含不断更改的属性(选定项)的类实现inotifypropertychanged并在选择更改时调用属性更改事件,则可以使用viewmodel中的MVVM完成所有这一切
 lstTables.ItemsSource = _dm.Data; //ListView
 dgImported.DataContext = _dm.Data; //DataGrid

    <ListView x:Name="lstTables" ItemsSource="{Binding SeriesName}" SelectedItem="{Binding XYPoints}"/>
                        <DataGrid x:Name="dgImported" Grid.Column="1" ItemsSource="{Binding XYPoints}"/>