11-11-2010 09:05 AM
Is it possible to put a WPF control in a .NET container? We are trying but the assembly (dll) always says there are no public controls.
John
11-11-2010 09:27 AM
There is currently no support for WPF in LabVIEW. You could post an idea in the LabVIEW Idea Exchange.
11-14-2010 09:10 AM
I believe you have to wrap the WPF control in a windows form. Then you can insert it into a .NET container.
12-20-2012 12:19 AM
Hi Jarrod,
Does the latest LabView 2012 support WPF control now? Or I still have to wrap the WPF control in a windows form?
Thanks
Daniel Hou
12-21-2012 11:52 AM
Daniel
There is still no native support for WPF in LabVIEW. The most recent release of Measurement Studio has added support for WPF, but as of yet, no decision has been made as to whether or not it will be added in future versions of LabVIEW. As always, you can make a feature request on the LabVIEW Idea Exchange.
For now, you should still be able to wrap your control in a Windows Form and add it in a .NET Container.
02-15-2013 10:35 AM
I am attempting to host a WPF control in a Windows Forms app. Outside LabVIEW, using a .Net test client, everything seems to work fine. However, when I attempt opening this form in LabVIEW, we receive an Error 1172 indentifying that it needs to be a STA.
I have, or so I thought, made this a STA with the following approach using TaskScheduler and Task. However, I am receiving the same error. Is there some specific approach that LabVIEW requires for this to work?
public void DisplayForm() { try { TaskScheduler taskUI = TaskScheduler.FromCurrentSynchronizationContext(); Task deploymentTask = Task.Factory.StartNew(() => { this._wpfControlHost.OnReadyToTest += this._wpfControlHost_OnReadyToTest; this._wpfControlHost.ShowDialog(); this._wpfControlHost.BringToFront(); },CancellationToken.None, TaskCreationOptions.LongRunning, taskUI); } catch (Exception ex) { // ToDo: // Log // Present user with error message } }
02-18-2013
03:29 PM
- last edited on
05-01-2025
01:40 PM
by
Content Cleaner
Because WPF does not natively speak to LabVIEW it appears that you want to wrap the WPF control into a .NET I'm not 100% sure this will work but here are some useful web pages.
These two would be best to read first, they describe how LabVIEW interacts with .NET
https://www.ni.com/docs/en-US/bundle/labview/page/using-net-with-labview.html
https://www.ni.com/docs/en-US/bundle/labview/page/loading-net-assemblies.html
These will give you a good idea of what is needed to make this work.
http://msdn.microsoft.com/en-us/library/ms182351(v=vs.80).aspx
http://www.blayd.co.uk/article.aspx?pageid=1014
I'm not super familiar with WPF but good luck and I encourage others to help because this is an interesting application to say the least.
02-18-2013 03:56 PM
Ryan,
Thanks for the info. Just so you are aware, this is a Windows Forms app hosting the WPF control. Some of the posts above indicated this would be the way to go. So, I think I am on the right path, there is just the STA issue that I am attempting to resolve at this point.
I'll take a look at the links you sent. Perhaps they will help.
Regards,
Chad
02-19-2013 12:58 PM
Could you state exactly the phrase of the error that is showing up? Is this an error in LabVIEW or Windows? I might be able to look up this error and give you further troubleshooting.
02-19-2013 07:44 PM
I don't have the exact phrase at the moment. I can get it from the LabVIEW guy...I'm the .Net guy.
In the meantime it's, Error 1172, Something about a Single Threaded Apartment and that some UIs require that.
Similar to this:
The calling thread must be STA, because many UI components require this.) <append><b>System.InvalidOperationException</b>
Thanks,
Chad