WPF 两个控件共享数据
<DataGrid x:Name="deliver" ItemsSource="{Binding Path=deliverdata.data}" Visibility="Collapsed"> <DataGrid.Columns> <DataGridTextColumn Width="0.2*" Binding="{Binding time, StringFormat=yyyy-MM-dd HH:mm:ss}" Header="时间" /> <DataGridTextColumn Width="0.8*" Binding="{Binding context}" Header="地点和跟踪进度" /> </DataGrid.Columns> </DataGrid>
引用控件数据
<DataGrid Grid.Row="1" ItemsSource="{Binding ElementName=deliver,Path=ItemsSource}" > <DataGrid.Columns> <DataGridTextColumn Width="0.2*" Binding="{Binding time, StringFormat=yyyy-MM-dd HH:mm:ss}" Header="时间" /> <DataGridTextColumn Width="0.8*" Binding="{Binding context}" Header="地点和跟踪进度" /> </DataGrid.Columns> </DataGrid>