如何对ItemsControl进行额外控制

时间:2018-03-14 15:10:48

标签: c# wpf xaml mvvm

我正在构建一个包含ItemsControl元素的Grid。每次将项目添加到ObservableCollection时,都会在Grid中创建新的ItemsControl控件。现在我在每个网格控件之间有一些余量,但我想在每个控件之间有一个TextBox,但我无法正确添加它。

如果我的网格在项目控件中看起来像这样

----------------

----------------

   I would want the text box here.

----------------

----------------

  And here

----------------

----------------

截至目前,这是我的ItemsControl

<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1" Grid.ColumnSpan="4">
                    <ItemsControl Grid.Row="1" Grid.ColumnSpan="3" ItemsSource="{Binding StudentsInClassCollection}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Grid Grid.Row="1"  Grid.ColumnSpan="3" Margin="5, 0, 15, 50" Height="70">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="80"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <CheckBox VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                    <Grid Grid.Column="1">
                                        <Border BorderThickness="1" BorderBrush="{Binding StudentMemberColor}">
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="40"/>
                                                    <ColumnDefinition Width="80"/>
                                                    <ColumnDefinition Width="*"/>
                                                </Grid.ColumnDefinitions>
                                                <dxe:TextEdit Grid.Column="1" Margin="5, 5, 5, 5" Width="50"  Height="50" HorizontalContentAlignment="Center"
                                                              FontFamily="Helvetica" FontWeight="Thin" FontSize="16"
                                                              Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"/>
                                            </Grid>
                                        </Border>
                                    </Grid>
                                </Grid>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </ScrollViewer>

0 个答案:

没有答案