I have a GLFW3 OpenGL project written in C++. I was looking to create a modern GUI to go with it. I have limited experience with XAML and windows WPF but it is intuitive to work with so I really want this to work.
I found 'WpfUnmanagedOpenGL' template from Github https://github.com/kopaka1822/WpfUnmanagedOpenGL and it runs great with a C++ DLL communicating with the Csharp OpenGL host window that is already working within the form using GLAD, not GLFW.
I managed to create a GLFW window with my existing code and it displays as a second popup window when the WPF form is compiled and run. See:
How can I embed this correctly?
I found this question on StackOverflow: embed window(glfwCreateWindow) as child to C++ MFC parent form .
Essentially it says I can set the GLFW window to be a child window of the WPF form. However I cannot get the WPF parent window handle to set it all up.
PLEASE help.
Thanks,
You may want to try to do the opposite. Rather than embedding your Win32 app inside your WPF form, embed your WPF form within your Win32 app instead.
Official docs:
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/walkthrough-hosting-wpf-content-in-win32?view=netframeworkdesktop-4.8
A really neat tutorial:
https://www.codeproject.com/Articles/5253279/Create-An-Awesome-WPF-UI-for-Your-Cplusplus-QT-App
This is for the legacy .NET Framework though. I have no clue if the same technique can be applied in the new .NET Core framework though.
I have developed a user control in WPF which draws some graphs.
Now i have to show this user control in a Silverlight application (to show on ASP.net webpage).
Is this possible to use a WPF user control in a Silverlight application?
I have searched on Google, but have not found a satisfactory answer.
No, it is not possible to show a WPF control in Silverlight. They use two different runtimes so are not directly substitutable with each other.
You have a few options though:
use XBAP to show WPF within the browser
rewrite your control so that you can compile a version for Silverlight or WPF (this is (was) quite a common way to do it)
Edit:
in response to your comment you seem to have some misunderstandings, I think you haven't understood the links I gave you. You may also have misunderstood what Silverlight is - just in case you have let me mention that Silverlight runs as a plugin within the web page, it isn't directly part of the HTML structure.
For the XBAP approach the WPF control/page is hosted inside a web page - just like a Silverlight control is. However you don't have direct access to the local filesystem or network filesystem (or databases running on the network) - Silverlight is the same, to access a database you really need to go via a WCF service.
With the second approach you have two versions (one for WPF, one for Silverlight) of your control and you use compile time targeting to dictate which control is built. You then use the appropriate control in the appropriate project.
I created another WPF project in my asp.net project solution and now want to use my WPF controls in my web application. Is it possible to use wpf control in my web projects?? I figure out on internet some says like you have to use Silverlight for web applicaitons. As far I know silverlight is subpart of WPF, so why not i can use WPF??. I have to use WPF controls because already did enough efforts to build wpf controls and now wanna to use in Web application.
Yes, you can embed WPF controls in a webpage, but you'll need the relevant plug-in enabled (much like Silverlight).
As an example the Xceed Datagrid for WPF is viewable within Internet Explorer.
Although XAML applications are disabled by default, you'll need to enable them in your Internet Explorer security settings.
As for Firefox, you'll need both the .Net Framework Assistant, and WPF Plugin as suggested by MSDN.
WPF is a really great framework, and enabling WPF/XAML based applications for intranet usage would be fine (you could inherit the security permissions through group policy), or for a set audience who don't mind the extra configuration.
The only way you can achieve that is by using Silverlight components not WPF. As you said silverlight is a subset of WFP, so not all WPF features are supported but the silverlight runner. For the most part, the visuals are fully compatible, that is user controls, so if you did not use anything that is specific to WPF then you should be grand.
maybe check here:
WPF vs Silverlight
BTW can you post your xaml, so that we get an idea?
Marco
I believe you can use the XML WPF Browser application to do this, but I'd probably not recommend it, as I think your users will have to download client-side components in order for it to run. The following link gives more info.
http://msdn.microsoft.com/en-us/library/aa970060.aspx
No you cannot use WPF in a web page. WPF is for Windows Applications and will only run on Windows machines. The internet is device agnostic and will run on Windows, Linux, Android, iOS etc. Therefore you need to use ASP .NET (or similar) for web applications and WPF for Windows.
Silverlight is a sub-set of WPF and will work on a web page... BUT not all devices support it (i.e. iOS). So if you really want to be system agnostic and true to the spirit of the web use HTML / CSS and JavaScript.
Whatever it is possible or not, the using of WPF controls embedded in a html page is just horrible.
A classic WPF control might be running (after changed browser settings), but there are many security concerns. Furthermore you have to show your users a to do list before anyone could see the real page.
Silverlight as a subset of WPF, but it is also a plugin that is not available for all platforms such as, for instance, iOS.
I recommend to use HTML 5, which is a per se standard and viewable on all other platforms. It causes more effort, but is is definitely worth it.
Although there are ways to do this (already mentioned by other users on this page), relying on your visitors to have this configured or plugins installed in their browsers means it's very risky to implement this (assuming your target is the WWW and not just local users).
I would consider building a web application UI and just reference everything via class libaries (if using N Tier design)
How can one set GridLayout known from Java or Wpf in WinForms control? Is it available by default or does it require writing some code (custom LayoutEngine implementation)?
Yes, it is available by default. If you are using Visual Studio, just drag it from toolbox to your form and set properties.
As far as I know Windows Forms work totally different from Java and WPF forms. One of thier differences is that there's no layout for windows forms whatsoever, instead there's this ability that you can place a control whenever you would like using its location property.
I'm looking for any resources on hosting a WPF form within an existing MFC application. Can anyone point me in the right direction on how to do this?
From what I understand (haven't tried myself), it's almost as simple as just giving the WPF control the parent's handle. Here's a Walkthrough: Hosting WPF Content in Win32.