0

我与Silverlight 4个中的XAML页面中使用数据绑定的一些问题,这是我的问题:的Silverlight 4 - 两个数据网格之间的结合,从混合4

我有两个数据网格:

<sdk:DataGrid x:Name="dgCodeCountry" Height="144" Margin="41,56,39,0" VerticalAlignment="Top" AutoGenerateColumns="False" ItemsSource="{Binding Collection}" > 
    <sdk:DataGrid.Columns> 
    <sdk:DataGridTextColumn Binding="{Binding Code}" Header="Code"/> 
    <sdk:DataGridTextColumn Binding="{Binding Name}" Header="Name"/> 
    </sdk:DataGrid.Columns> 
</sdk:DataGrid> 


<sdk:DataGrid x:Name="dgStateOfProvince" Height="64" Margin="10,17,10,0" VerticalAlignment="Top"> 
    <sdk:DataGrid.Columns> 

    </sdk:DataGrid.Columns> 
</sdk:DataGrid> 

第一Datagrid dgCodeCountry通过使用Blend4 Sample Data功能填充数据。当我从dgCodeCountry中选择一行时,我希望该行出现在dgStateOfProvince中。而这些数据网格可以位于usercontrol或xaml页面的任何位置。

我该如何设法做到这一点?

回答

1

绑定dgStateOfProvince的的ItemsSource到dgCodeCountry的SelectedItems:

<sdk:DataGrid x:Name="dgStateOfProvince" ItemsSource="{Binding ElementName=dgCodeCountry Path=SelectedItems}"> 
+0

谢谢。 毕竟我没有用这种方法去,但现在我明白了路径= ...部分:)。 – andreiursan 2010-07-22 05:59:41