I'm posting this as an answer so that I can format the text.
@RetiredGeek I believe I mentioned that I know I can set each control's visibility but my code is already getting spaghetti-like without an extra 90-odd lines enabling/disabling that property. –
@Cpt.Whale I just tried a ContentControl but because I'm loading the XAML from a file, I get this error:
WARNING: XML Load failed with error: Exception calling "Load" with "1"
argument(s): "'Content' property has already been set on
'ContentControl'." Exception calling "Load" with "1" argument(s):
"'Content' property has already been set on 'ContentControl'." At
[path_to_my_project]\test.ps1:58 char:2 –
Here's how I'm loading the XAML:
$InputXAML_FullName = Convert-Path $ScriptDir\Form.xaml
# Load the file
$InputXAML = [IO.File]::ReadAllText($InputXAML_FullName)
#===========================================================================
# Remove stuff we don't want
#===========================================================================
$InputXAML = $InputXAML -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^<Win.*', '<Window'
#===========================================================================
# Read the cleaned-up XAML
#===========================================================================
[xml]$xmlDoc = $InputXAML
$XAML_Reader=(New-Object System.Xml.XmlNodeReader $xmlDoc)
Try {
$Form=[Windows.Markup.XamlReader]::Load($XAML_Reader)
}
Catch {
Write-Warning "XML Load failed with error: $($Error[0])"
Throw
}
I think I'm going to have to re-jig my grids and use a nested grid inside one of them.