WPF 滚动条丢失 - 另一个列表框中的内部列表框中没有显示滚动条

WPF Scrollbar missing - There is no scrollbar shown in the inner listbox inside another list box

在我的示例中,我有一个列表框 (CommentsList)。列表中的每个项目都有另一个内部列表 (repliesList)。当我有一些评论时,会显示垂直滚动条,但当我有列表评论或重播时,不会显示垂直滚动条。 这里是xaml的设计,请问哪里出错了?

CommentsPanel.xaml:

 <DockPanel LastChildFill="True" HorizontalAlignment="Stretch" VerticalAlignment="Top">
            <TextBlock DockPanel.Dock="Bottom" TextWrapping="Wrap" Visibility="{Binding HasComments, Converter={StaticResource reversedBooleanToVisibilityConverter}}" Text="There are no comments on this row." x:Name="NoCommentsLabel"/>
            <TextBlock DockPanel.Dock="Bottom" TextWrapping="Wrap"  Text="Use Previous and Next to navigate throught all comments." x:Name="NoCommentsOpenDiagramsLabel">
                <TextBlock.Visibility>
                    <MultiBinding Converter="{StaticResource multiBooleanToVisibilityConverter}">
                        <Binding Path="HasComments"/>
                        <Binding Path="CommentsOnOpenDiagrams" />
                    </MultiBinding>
                </TextBlock.Visibility>
            </TextBlock>
            <ListBox DockPanel.Dock="Bottom" x:Name="CommentsList" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding Path=CommentsListItems.View}" 
                        HorizontalContentAlignment="Stretch" BorderThickness="0" Background="Transparent"  SelectionMode="Single" SelectionChanged="CommentsList_OnSelectionChanged"
                        Width="{Binding Width, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}, AncestorLevel=1}}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <wpfControlLibrary:CommentThread Margin="2,2,5,5" IsSelected="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}}, UpdateSourceTrigger=PropertyChanged}"
                                Width="{Binding Width, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}, AncestorLevel=1}}">
                        </wpfControlLibrary:CommentThread>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </DockPanel>

wpfControlLibrary:评论线程:

<Border x:Name="borderMain" BorderBrush="Transparent" BorderThickness="1" Background="#00000000" Padding="3">
        <Grid x:Name="commentGrid">
            <Grid x:Name="threadGrid" Grid.Column="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*"/>
                    <RowDefinition  Height="Auto" />
                </Grid.RowDefinitions>
              <ContentPresenter Grid.Row="0" Grid.Column="0" Content="{Binding Path=CommentModel}">
                <ContentPresenter.Style>
                  <Style TargetType="ContentPresenter">
                   <Setter Property="ContentTemplate" Value="{StaticResource NoLyncTemplate}" />
                  </Style>
                </ContentPresenter.Style>
              </ContentPresenter>
                **<ListBox Margin="50, 0, 0 0" Grid.Row="1" x:Name="repliesList" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemContainerStyle="{StaticResource ContainerStyle}" HorizontalContentAlignment="Stretch" SelectionChanged="RepliesList_OnSelectionChanged" BorderThickness="0" Background="Transparent"  SelectionMode="Single" Grid.Column="0" Grid.ColumnSpan="2" Width="{Binding Width, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}, AncestorLevel=1}}" ItemsSource="{Binding Path=CommentRepliesListItems.View}"**
                     >
                <Grid Grid.Row="3" Margin="50,0,0,0" >
                <TextBlock x:Name="watermark_TextBlock" Text="Reply..." Foreground="{StaticResource brushWatermarkForeground}" Background="{StaticResource brushWatermarkBackground}"
Width="{Binding ActualWidth, ElementName=threadGrid, Mode=OneWay}" HorizontalAlignment="Left" MouseLeftButtonUp="Watermark_OnMouseLeftButtonUp" KeyUp="Watermark_KeyUp">
                    <TextBlock.Style>
                        <Style TargetType="TextBlock">
                            <Style.Triggers>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsMouseOver" Value="True"></Condition>
                                        <Condition Property="Visibility" Value="Visible"></Condition>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Cursor" Value="IBeam"></Setter>
                                </MultiTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBlock.Style>
                </TextBlock>
                <TextBox x:Name="replyBox" Text="" Visibility="Collapsed"                          HorizontalAlignment="Stretch" TextWrapping="Wrap" VerticalAlignment="Top" Height="40"
                         VerticalScrollBarVisibility="Auto" LostFocus="CommentEdit_OnLostFocus"
                         KeyUp="ReplyBox_OnKeyUp"
                    />
            </Grid>
            </Grid>
        </Grid>
    </Border>

解决方案是在列表框中使用物理滚动而不是逻辑滚动: ScrollViewer.CanContentScroll="假"