Silverlight 4 - 两个数据网格之间的绑定,来自 Blend 4

发布于 2024-09-10 18:08:01 字数 882 浏览 3 评论 0原文

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

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

我怎样才能做到这一点?

I have some issues with using databinding in silverlight 4 xaml pages, this is my problem:

I have two data grids:

<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 is filled with data by using Blend4 Sample Data feature. When I select one row from dgCodeCountry, I want that row to appear into dgStateOfProvince. And those datagrids can be anywhere within a usercontrol or xaml page.

How can I manage to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮光之海 2024-09-17 18:08:01

将 dgStateOfProvince 的 ItemsSource 绑定到 dgCodeCountry 的 SelectedItems:

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

Bind the ItemsSource of dgStateOfProvince to SelectedItems of dgCodeCountry:

<sdk:DataGrid x:Name="dgStateOfProvince" ItemsSource="{Binding ElementName=dgCodeCountry Path=SelectedItems}">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文