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.
This topic is 6 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Alex.ferrie
Posts: 7
Last visit: Mon Jun 18, 2018 1:01 am

WPF controls in PSS

Post by Alex.ferrie »

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: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: WPF controls in PSS

Post by Alexander Riedel »

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 7937 times
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Alex.ferrie
Posts: 7
Last visit: Mon Jun 18, 2018 1:01 am

Re: WPF controls in PSS

Post by Alex.ferrie »

Hi Alex, thanks for the quick response. How do I then get access to the WPF controls?
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: WPF controls in PSS

Post by Alexander Riedel »

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
Last visit: Mon Jun 18, 2018 1:01 am

Re: WPF controls in PSS

Post by Alex.ferrie »

Hi Alex, not heard anything back. Do you want me to post this elsewhere?
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: WPF controls in PSS

Post by Alexander Riedel »

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: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: WPF controls in PSS

Post by davidc »

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.
This topic is 6 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked