想要合并来自两个不同网格的数据
我正在开发一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将控件从第二个网格克隆到第一个网格并进行绑定,以便两者显示相同的数据。
You should clone the control from the second grid into the first and make a binding so both display same data.