2024-10-28 16:53:03 -05:00
function Initialize-InstallAppArea {
<#
. SYNOPSIS
Creates a [ Windows.Controls.ScrollViewer] containing a [Windows.Controls.ItemsControl ] which is setup to use Virtualization to only load the visible elements for performance reasons .
2024-11-02 07:51:48 -05:00
This is used as the parent object for all category and app entries on the install tab
2024-10-28 16:53:03 -05:00
Used to as part of the Install Tab UI generation
2024-11-02 07:51:48 -05:00
2024-10-28 16:53:03 -05:00
. PARAMETER TargetElement
2024-11-02 07:51:48 -05:00
The element to which the AppArea shoud be added
2024-10-28 16:53:03 -05:00
#>
param ( $TargetElement )
$scrollViewer = New-Object Windows . Controls . ScrollViewer
$scrollViewer . VerticalScrollBarVisibility = 'Auto'
$scrollViewer . HorizontalAlignment = 'Stretch'
$scrollViewer . VerticalAlignment = 'Stretch'
$scrollViewer . CanContentScroll = $true
$itemsControl = New-Object Windows . Controls . ItemsControl
$itemsControl . HorizontalAlignment = 'Stretch'
$itemsControl . VerticalAlignment = 'Stretch'
$itemsPanelTemplate = New-Object Windows . Controls . ItemsPanelTemplate
$factory = New-Object Windows . FrameworkElementFactory ( [ Windows.Controls.VirtualizingStackPanel ] )
$itemsPanelTemplate . VisualTree = $factory
$itemsControl . ItemsPanel = $itemsPanelTemplate
$itemsControl . SetValue ( [ Windows.Controls.VirtualizingStackPanel ] :: IsVirtualizingProperty , $true )
$itemsControl . SetValue ( [ Windows.Controls.VirtualizingStackPanel ] :: VirtualizationModeProperty , [ Windows.Controls.VirtualizationMode ] :: Recycling )
$scrollViewer . Content = $itemsControl
[ Windows.Controls.DockPanel ] :: SetDock ( $scrollViewer , [ Windows.Controls.Dock ] :: Bottom )
$null = $TargetElement . Children . Add ( $scrollViewer )
return $itemsControl
2024-11-02 07:51:48 -05:00
}