【问题标题】:Silverlight 4 - binding between two datagrids, from blend 4Silverlight 4 - 两个数据网格之间的绑定,来自 blend 4
【发布时间】:2010-07-20 10:49:55
【问题描述】:

我在 silverlight 4 xaml 页面中使用数据绑定有一些问题,这是我的问题:

我有两个数据网格:

<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>

First Datagrid dgCodeCountry 使用 Blend4 样本数据功能填充数据。当我从 dgCodeCountry 中选择一行时,我希望该行出现在 dgStateOfProvince 中。这些数据网格可以位于用户控件或 xaml 页面中的任何位置。

我怎样才能做到这一点?

【问题讨论】:

    标签: silverlight data-binding xaml silverlight-4.0 expression-blend


    【解决方案1】:

    将dgStateOfProvince的ItemsSource绑定到dgCodeCountry的SelectedItems:

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

    【讨论】:

    • 谢谢。毕竟我没有采用这种方法,但现在我理解了 Path=... 部分:)。
    猜你喜欢
    • 1970-01-01
    • 2011-09-14
    • 1970-01-01
    • 2023-03-13
    • 2011-02-20
    • 1970-01-01
    • 1970-01-01
    • 2012-07-28
    • 1970-01-01
    相关资源
    最近更新 更多