mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-29 01:11:30 -06:00
37 lines
1.8 KiB
PowerShell
37 lines
1.8 KiB
PowerShell
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.
|
|
This is used as the parent object for all category and app entries on the install tab
|
|
Used to as part of the Install Tab UI generation
|
|
|
|
.PARAMETER TargetElement
|
|
The element to which the AppArea shoud be added
|
|
|
|
#>
|
|
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
|
|
}
|