Wpf Listbox最后一个元素渲染不正确

Wpf Listbox最后一个元素渲染不正确,wpf,Wpf,我的列表框有问题。请检查下面的屏幕截图。最后一个元素有点被listbox外部边框“吃掉”(我定义了适当的MaxHeight)。有人能帮我吗 <DataTemplate x:Key="QCTemplate"> <Grid> <Expander x:Name="expander" Header="{Binding}"> <Expander.HeaderTemplate> &

我的列表框有问题。请检查下面的屏幕截图。最后一个元素有点被listbox外部边框“吃掉”(我定义了适当的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>

Количество цитат:

Code或properties screen needed@ССццПцц不带XAML无法确定,但我打赌您使用的是垂直StackPanel之类的东西,它不关心您的最大高度set@dkozl我更新了我的code@MarcinZdunekUpdateEdit真的很奇怪,但解决方案是删除这个:Height=”{Binding ElementName=ComponentChildsListBox,Path=ActualHeight}”。有人能解释一下吗?