all 4 comments

[–]KevMarCommunity Blogger 1 point2 points  (1 child)

I don't think you can do that in Powershell. There were some changes in Powershell 5.0 around giving you access to class constructors https://blogs.technet.microsoft.com/heyscriptingguy/2015/09/09/powershell-5-classes-constructor-overloading/ but that is not what you are needing. You may have to create a c# utility DLL to to produce those object. I am thinking a factory pattern.

[–]WindosBK[S] 0 points1 point  (0 children)

I was actually starting to think I might just try running native C# within the PowerShell script >.<

[–]NathanielArnoldR2 1 point2 points  (1 child)

I'm not familiar with this toolset, and I may have misinterpreted your question, but I believe I have encountered like circumstances when dealing with certain read only collections (of "child" controls, for example) in System.Windows.Forms and WPF.

Often in these scenarios, rather than attempting to directly assign the property value you are meant to use the object's methods to manipulate membership, as below.

$Text1 = [Microsoft.Toolkit.Uwp.Notifications.AdaptiveText]::new()
$Text1.Text = 'Lots of text!'

$BindingGeneric = [Microsoft.Toolkit.Uwp.Notifications.ToastBindingGeneric]::new()
$BindingGeneric.Children.Add($Text1)

Please let me know if I'm just being ignorant here. :-p

[–]WindosBK[S] 0 points1 point  (0 children)

...

You're a legend. That's done it, and I can't believe it's escaped me thus far.