WPF controls in PSS

Post feature requests, product enhancement ideas, and other product-specific suggestions here. Do not post bug reports.
Forum rules
Do not post any licensing information in this forum.
Locked
User avatar
Alex.ferrie
Posts: 7
Joined: Fri Jun 02, 2017 7:46 am

WPF controls in PSS

Post by Alex.ferrie » Tue Aug 08, 2017 4:10 am

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

Are there any plans to make WPF controls available within the PSS forms designer?

User avatar
Alexander Riedel
Posts: 6671
Joined: Tue May 29, 2007 4:43 pm

Re: WPF controls in PSS

Post by Alexander Riedel » Tue Aug 08, 2017 5:10 am

Not seamless, these are two incompatible technologies as far as the designer goes. WPF more or less requires you to write XAML, basically spelling everything out in XML.
You can use WPF controls with a Windows Form environment though. There is a control set "ElementHost – WPF Control Host" that you can add to your form to include WPF controls.
Attachments
2017-08-08_5-08-20.png
2017-08-08_5-08-20.png (66.59 KiB) Viewed 2548 times
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
Alex.ferrie
Posts: 7
Joined: Fri Jun 02, 2017 7:46 am

Re: WPF controls in PSS

Post by Alex.ferrie » Tue Aug 08, 2017 5:17 am

Hi Alex, thanks for the quick response. How do I then get access to the WPF controls?

User avatar
Alexander Riedel
Posts: 6671
Joined: Tue May 29, 2007 4:43 pm

Re: WPF controls in PSS

Post by Alexander Riedel » Tue Aug 08, 2017 5:29 am

I will let the expert answer this. Folks will be in later during normal office hours.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
Alex.ferrie
Posts: 7
Joined: Fri Jun 02, 2017 7:46 am

Re: WPF controls in PSS

Post by Alex.ferrie » Mon Aug 14, 2017 4:08 am

Hi Alex, not heard anything back. Do you want me to post this elsewhere?

User avatar
Alexander Riedel
Posts: 6671
Joined: Tue May 29, 2007 4:43 pm

Re: WPF controls in PSS

Post by Alexander Riedel » Mon Aug 14, 2017 4:15 am

Hmm, sorry, not sure what happened. The best person for this is out of office this week. I will make sure to send emails until he answers :D
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
davidc
Posts: 5437
Joined: Thu Aug 18, 2011 4:56 am

Re: WPF controls in PSS

Post by davidc » Mon Aug 21, 2017 7:53 am

In order to access the controls within your XAML, you have to query the control and assign it to a variable.

Code: Select all

$script:WPFControl = Update-ElementHost -Elementhost $elementhost -XAML $xaml
	if($WPFControl)
	{
		$wpfButton = [System.Windows.Controls.Button]$WPFControl.FindName("WPFButton")
		
		if($wpfButton)
		{
			$wpfButton.Add_Click({Write-Host "WPF Button was clicked"})
		}
	}
If you want PowerShell Studio to provide PrimalSense, I recommend casting the object before assigning the variable:

$wpfButton = [System.Windows.Controls.Button]$WPFControl.FindName("WPFButton")

You may need to reference the WPF assembly first:
Add-Type -AssemblyName PresentationFramework
If you have the latest service release, you can set a breakpoint after the variable is assigned and PowerShell Studio will use the session state to provide PrimalSense.

For further GUI support, I recommend posting in the PowerShell GUIs forum:

viewforum.php?f=21
David
SAPIEN Technologies, Inc.

Locked