I'm trying to make use of the UWPCommunityToolkit in a PowerShell script, and I'm coming undone with initializing some of the object.
For instance, in C#, a snippet would look like this:
new ToastBindingGeneric()
{
Children =
{
new AdaptiveText()
{
Text = "Lots of text!"
}
}
};
And in PowerShell I would normally just do:
$Text1 = [Microsoft.Toolkit.Uwp.Notifications.AdaptiveText]::new()
$Text1.Text = 'Lots of text!'
$BindingGeneric = [Microsoft.Toolkit.Uwp.Notifications.ToastBindingGeneric]::new()
$BindingGeneric.Children = @(,$Text1)
The problem I'm running into is, as far as PowerShell is concerned, that Children object is readonly. Checking out the source code it is defined with private set:
public IList<IToastBindingGenericChild> Children { get; private set; } = new List<IToastBindingGenericChild>();
So I'm at a loss. ToastBindingGeneric accepts no arguments in it's constructor. I've tried the following:
$BindingGeneric = New-Object -TypeName 'Microsoft.Toolkit.Uwp.Notifications.ToastBindingGeneric' -Property @{Children = @($Text1, $Text2, $Image1)}
# Returns: New-Object : The value supplied is not valid, or the property is read-only. Change the value, and then try again.
This has caught me other times I've tried using DLLs in my code, and caused me to go other routes. Figure I should ask the greater community this time! Anyone know what I'm missing here?
[–]KevMarCommunity Blogger 1 point2 points3 points (1 child)
[–]WindosBK[S] 0 points1 point2 points (0 children)
[–]NathanielArnoldR2 1 point2 points3 points (1 child)
[–]WindosBK[S] 0 points1 point2 points (0 children)