ウィンドウのサイズではなく、コンテンツのサイズに基づいてウィンドウをスクロールしたい。現在、スクロールバーは、ウィンドウの高さがXAMLで指定された高さよりも低い場合にのみ表示されます。XAMLコードは次のとおりです。ここにある他のスレッドに基づいて、ScrollViewerをグリッドでラップするなどのさまざまなことを試しました。
<Window.Resources>
<src:ObservableSwitches x:Key="Switches"/>
<Style TargetType="{x:Type TreeViewItem}" x:Key="ModuleStyle">
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="FontSize" Value="12"/>
</Style>
<Style TargetType="{x:Type TreeViewItem}" x:Key="RedModuleStyle" BasedOn="{StaticResource ModuleStyle}">
<Setter Property="Foreground" Value="Red"/>
</Style>
</Window.Resources>
<ScrollViewer IsEnabled="True" VerticalScrollBarVisibility="Visible">
<Grid Margin="0,0,-211.4,-168">
<StackPanel HorizontalAlignment="Stretch" Name="StackPanel1" VerticalAlignment="Stretch" Width="Auto" Margin="0,0,188.6,114">
<StackPanel.Resources>
<Style TargetType="{x:Type Label}" x:Key="LabelStyle">
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="FontWeight" Value="Bold"/>
</Style>
</StackPanel.Resources>
<Label Content="Switch Name:" Name="Label1" Height="25" HorizontalAlignment="Left"/>
<Label Content="Software Version:" Name="Label2" HorizontalAlignment="Left" />
<Label Content="Model Number:" Name="Label3" HorizontalAlignment="left"/>
<Label Content="IP Address:" Name="Label4" HorizontalAlignment="left"></Label>
<Label Content="Serial Number:" Name="Label5" HorizontalAlignment="Left"></Label>
<Label Content="Show Tech Taken:" Name="Label6" HorizontalAlignment="left"/>
</StackPanel>
<StackPanel Margin="105,0,218,489">
<StackPanel.Resources>
<Style TargetType="{x:Type Label}" x:Key="LabelStyle">
<Setter Property="FontSize" Value="12"/>
<Setter Property="FontWeight" Value="Bold"/>
</Style>
</StackPanel.Resources>
<Label Content="{Binding switchName}" Name="SwitchNameLabel" HorizontalAlignment="left" />
<Label Content="{Binding swVersion}" Name="VersionLabel" HorizontalAlignment="left"/>
<Label Content="{Binding switchModel}" Name="ModelNumberLabel" HorizontalAlignment="Left"/>
<Label Content="{Binding IPAddress}" Name="IPAddressLabel" HorizontalAlignment="Left"/>
<Label Content="{Binding SerialNumber}" Name="SerialLabel" HorizontalAlignment="Left"/>
<Label Content="{Binding LastDataCaptureDate}" Name="ShowTechLabel" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Name="ContentPanel" HorizontalAlignment="Left" Height="Auto" Margin="0,185,0,0" VerticalAlignment="Top" Width="auto"
ScrollViewer.VerticalScrollBarVisibility="Auto">
<TreeView Name="ModulesTreeView" Height="auto" Background="GhostWhite" BorderThickness="0" Width="auto"/>
<TreeView Name="VSANTreeView" Height="auto" Background="GhostWhite" BorderThickness="0" Width="auto"/>
<TreeView Name="FCIPTreeView" MaxHeight="200" Background="GhostWhite" BorderThickness="0" Width="auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"/>
<TreeView Name="IVRTreeView" Height="Auto" Background="GhostWhite" BorderThickness="0" Width="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto">
<TreeViewItem Name="IVRTreeViewItem" Header="IVR Topology" Height="Auto" Background="GhostWhite" BorderThickness="0" Width="Auto">
<TreeViewItem Name="NatEnabled" Header="NAT Enabled" Background="GhostWhite" BorderThickness="0" Width="Auto">
<Label Name="NATLabel" Background="GhostWhite" BorderThickness="0" Width="Auto"></Label>
</TreeViewItem>
<TreeViewItem Name="Status" Header="Status" Background="GhostWhite" BorderThickness="0" Width="Auto">
<Label Name="StatusLabel" Background="GhostWhite" BorderThickness="0" Width="Auto"></Label>
</TreeViewItem>
<TreeViewItem Name="FabricDistributionEnabled" Header="Fabric Distribution" Background="GhostWhite" BorderThickness="0" Width="Auto">
<Label Name="FabricDistributionLabel" Background="GhostWhite" BorderThickness="0" Width="Auto"></Label>
</TreeViewItem>
<TreeViewItem Name="AFID" Header="AFID Listing" Background="GhostWhite" BorderThickness="0" Width="Auto">
<ListView Name="AFIDListView" >
</ListView>
</TreeViewItem>
</TreeViewItem>
</TreeView>
</StackPanel>
</Grid>
</ScrollViewer>