3
嘗試將滾動查看器添加到TextBlock,以便用戶可以向下滾動內容,這往往比可用的屏幕空間更長。對於什麼可能是一個愚蠢的問題表示抱歉:我可以看到有很多關於這個問題的主題,並且問題通常是固定的高度,但我很努力地看到哪些元素導致了我的XAML中的問題:WPF滾動查看器不能使用動態高度
<Popup StaysOpen="True" Placement="Center" IsOpen="{Binding SummaryOpen}" PlacementTarget="{Binding ElementName=Areas}">
<Border Background="LightGray" BorderBrush="Black" Padding="5" BorderThickness="1">
<Grid Width="500">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="350" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Label Content="{Binding Name}" />
<Label Content=": " />
<Label Content="{Binding Description}" />
</StackPanel>
<Border Grid.Row="1" BorderBrush="Black" BorderThickness="1">
<StackPanel Background="White" Margin="-1,1,1,-1">
<!-- this is the rogue element -->
<ScrollViewer VerticalScrollBarVisibility="Auto">
<TextBlock Text="{Binding Summary}" TextWrapping="Wrap" />
</ScrollViewer>
</StackPanel>
</Border>
</Grid>
</Border>
</Popup>
ScrollViewer出現,但從不包含實際的滾動條,無論TextBlock中有多少內容。
如果有人能解釋問題出在哪裏以及如何解決問題,我會非常感激。
啊,謝謝!我不知道StackPanels「默認」到無限高度,但感謝修復和有用的信息。 –