列表框最后一个元素错误呈现

时间:2015-12-12 18:01:06

标签: wpf

我遇到了列表框的问题。请检查那里的截图。最后一个元素是由列表框外部边框“吃掉”(我定义了适当的MaxHeight)。有人能帮我吗?

<DataTemplate x:Key="QCTemplate">
    <Grid>
        <Expander x:Name="expander" Header="{Binding}">
            <Expander.HeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical">
                        <TextBox Name="ComponentNameTextBlock" Style="{StaticResource BorderlessTextBoxStyle}" Text="{Binding ComponentName, Mode=TwoWay}" />
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Margin="1">Количество цитат:</TextBlock>
                            <TextBlock Name="ComponentVolumeTextBlock" Grid.Column="1" Margin="1" Text="{Binding Volume}" />
                        </Grid>
                    </StackPanel>
                </DataTemplate>
            </Expander.HeaderTemplate>

            <!-- Контекстное меню экспандера -->
            <Expander.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Оригинал 'My Clippings.txt'">
                        <MenuItem Header="Удалить из оригинала..." 
                                  Command="{StaticResource ResourceKey=DeleteFromMyClippingsCommand}"
                                  CommandParameter="{Binding}" />
                    </MenuItem>
                 </ContextMenu>
            </Expander.ContextMenu>

            <!-- Внутреннее содержание экспандера -->
            <Grid Name="ExpanderContentContainer" 
                  Height="{Binding ElementName=ComponentChildsListBox, Path=ActualHeight}">

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="25" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                    <Rectangle Grid.Column="0" Grid.Row="0"
                               Width="2" Height="{Binding Path=ActualHeight}"
                               Fill="Black" 
                               Margin="2"                               
                               />
                <StackPanel Orientation="Vertical" 
                            Grid.Column="1" Grid.Row="0">
                    <TextBox Name="ComponentCommentTextBox" 
                             Text="{Binding Comment, Converter={StaticResource ResourceKey=QCCCommentConvrtr}, Mode=TwoWay}"
                             BorderThickness="0"
                             GotFocus="ComponentCommentTextBox_GotFocus"
                             Margin="1"
                             />

                    <ListBox Name="ComponentChildsListBox"
                             BorderBrush="Transparent"
                             ItemsSource="{Binding ChildsCollection}"
                             ScrollViewer.CanContentScroll="False"
                             MaxHeight="300" 
                             Margin="1"
                             Style="{StaticResource LibraryViewListBoxStyle}"
                             />
                </StackPanel>
            </Grid>
        </Expander>
    </Grid>
</DataTemplate>

Screenshot

0 个答案:

没有答案