我需要圍繞由項目控件填充的虛擬化堆疊面板的滾動查看器。顯然,高度是無限的,這就是爲什麼它沒有虛擬化。爲什麼?更多虛擬化堆棧面板高度/慢度問題
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ScrollViewer>
<ItemsControl ItemsSource="{Binding InterestingHosts}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel IsItemsHost="True" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock FontSize="14"><TextBlock Text="{Binding Host.HostName}" FontWeight="Bold" FontSize="18" /> (<TextBlock Text="{Binding Host.IPAddress}" />)</TextBlock>
<StackPanel>
<StackPanel.Style>
<Style TargetType="StackPanel">
<Setter Property="Margin" Value="10" />
<Style.Triggers>
<DataTrigger Binding="{Binding LoggedOnUsers.Count}" Value="0">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<TextBlock Text="The follow domain and/or enterprise admins are logged on to the host: "/>
<DataGrid AutoGenerateColumns="False" IsReadOnly="True" ItemsSource="{Binding LoggedOnUsers}">
<DataGrid.Columns>
<DataGridTextColumn Width="200" Binding="{Binding Domain}" Header="Domain"/>
<DataGridTextColumn Width="200" Binding="{Binding Name}" Header="Username"/>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
<StackPanel>
<StackPanel.Style>
<Style TargetType="StackPanel">
<Setter Property="Margin" Value="10" />
<Style.Triggers>
<DataTrigger Binding="{Binding Processes.Count}" Value="0">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<TextBlock Text="The follow domain and/or enterprise admins are running processes on the host: "/>
<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Processes}" IsReadOnly="True">
<DataGrid.Columns>
<DataGridTextColumn Width="200" Header="Name" IsReadOnly="False" Binding="{Binding Name}"/>
<DataGridTextColumn Width="200" Binding="{Binding Username}" Header="Username" />
<DataGridTextColumn Binding="{Binding ID}" Header="ID" />
</DataGrid.Columns>
</DataGrid>
</StackPanel>
<StackPanel>
<StackPanel.Style>
<Style TargetType="StackPanel">
<Setter Property="Margin" Value="10" />
<Style.Triggers>
<DataTrigger Binding="{Binding Services.Count}" Value="0">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<TextBlock Text="The follow domain and/or enterprise admins are authenticated for services on the host: "/>
<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Services}" IsReadOnly="True">
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}" />
<DataGridTextColumn Header="Username" Binding="{Binding Username}" />
<DataGridTextColumn Header="Start Mode" Binding="{Binding StartMode}" />
<DataGridTextColumn Header="State" Binding="{Binding State}" />
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>