想要合并来自两个不同网格的数据

发布于 2024-11-19 04:29:46 字数 1646 浏览 2 评论 0原文

我正在开发一个 silverlight 应用程序,并动态创建网格,每个网格都有一行和两列。在第一个网格中,我用一些字段(文本框/组合框/日期选择器等)填充列,并将第 2 列留空。在第二个网格中,我填充第二列并保留第一列空白,依此类推。现在我想要第一个网格中第二个网格中第二列的数据。 (在某种程度上我想合并两个网格)。有什么办法可以做到这一点吗?

它是这样的:

   <Grid>
   <views:DynamicFieldsView IsTabStop="True" Grid.Column="0" DataContext="{Binding   Path=FieldProperties}" />
    </Grid>

而dynamicFieldsView是这样的:

<Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="{Binding GridColumnNumber}" width = 140 ....>

<Controls:FieldItemControl FieldType="{Binding Type}" Margin="10,0,0,0" Grid.Column="{Binding FieldGridColumnNumber}">
<Controls:FieldItemControl.DataTemplates>
<Controls:TemplateSelectorDataTemplate FieldType="TextBox">  
          <TextBox Text="{Binding UserText}" width = 200 ....>
</Controls:TemplateSelectorDataTemplate>
<Controls:TemplateSelectorDataTemplate FieldType="Button">
          <Button x:Name="SearchButton" Margin="10 10 10 0" .....>
</Controls:TemplateSelectorDataTemplate>
<Controls:TemplateSelectorDataTemplate FieldType="DropDownList">
          <DynamicControls:AutoCompleteComboBox VerticalAlignment="Top" Width =200 ....>
</Controls:TemplateSelectorDataTemplate>

 ....
 ....
 ....
 </Controls:FieldItemControl.DataTemplates>
 </Controls:FieldItemControl>
 </Grid>

I am working on a silverlight application and am creating girds dynamically with each having one row and two columns. In the first grid I am populating column with some fields(text box/ combobox/ datepicker etc) and leaving column 2 blank. In the second grid I am populating the second column and leaving the first blank and so on alternately. Now I want the data from the second column in the second grid in the first grid. (In a way I want to merge two grids). Is there any way to do that?

It goes something like this:

   <Grid>
   <views:DynamicFieldsView IsTabStop="True" Grid.Column="0" DataContext="{Binding   Path=FieldProperties}" />
    </Grid>

And the dynamicFieldsView is like this:

<Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="{Binding GridColumnNumber}" width = 140 ....>

<Controls:FieldItemControl FieldType="{Binding Type}" Margin="10,0,0,0" Grid.Column="{Binding FieldGridColumnNumber}">
<Controls:FieldItemControl.DataTemplates>
<Controls:TemplateSelectorDataTemplate FieldType="TextBox">  
          <TextBox Text="{Binding UserText}" width = 200 ....>
</Controls:TemplateSelectorDataTemplate>
<Controls:TemplateSelectorDataTemplate FieldType="Button">
          <Button x:Name="SearchButton" Margin="10 10 10 0" .....>
</Controls:TemplateSelectorDataTemplate>
<Controls:TemplateSelectorDataTemplate FieldType="DropDownList">
          <DynamicControls:AutoCompleteComboBox VerticalAlignment="Top" Width =200 ....>
</Controls:TemplateSelectorDataTemplate>

 ....
 ....
 ....
 </Controls:FieldItemControl.DataTemplates>
 </Controls:FieldItemControl>
 </Grid>

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

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

发布评论

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

评论(1

屋顶上的小猫咪 2024-11-26 04:29:46

您应该将控件从第二个网格克隆到第一个网格并进行绑定,以便两者显示相同的数据。

You should clone the control from the second grid into the first and make a binding so both display same data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文