I would like to run a shell window manager kiosk-style WPF app that is full screen and contains in it other WPF apps.
Each WPF app is a project of it's own in my VS solution, what are the best practices for loading an instance of the other apps into my shell app and (preferably) confine them to certain bounds within the window manager.
I would try to rethink your design.
Instead of trying to load "other WPF Applications", it would be far simpler to load Windows, or potentially even better, UserControls, from the other assemblies (projects/solutions) and display them directly within your Application.
Extensibility like this can be accomplished fairly easily via MEF, which is built into the framework. This would allow you to define contracts that can be loaded dynamically in your main application, and used to build the functionality as needed.
Related
I am currenlty developing a plugin for an existing 3rd part system. The plugin exposes a GUI, which is defined to be WPF by the plugin framework. However, i have to integrate a legacy WinForms control that is hidden in a library (no source code available).
Using WinFormsHost works great, as long as the Display scaling is set to 100%. If the settings are different, my embedded WinForms control scales awkward and doesn't look good anymore.
If I create a WinForms Window and embed the control, scaling is fine.
If I create the same window from a WPF application / Window and push the WinForms window into the WPF window with HwndHost, scaling is awkward again.
It seems that scaling is only correct when i start my WinForms window in a separate process outside the 'WPF' environment.
I should be able to catch the separate process' window and get proper scaling, but communication into my legacy window may become tricky then.
Is there a way to get proper scaling without the detour via a separate process? I know that similar questions have been posted here, but so far i did not find what i was looking for.
Thanks in advance.
I have a win form application and i'm trying to run it inside the web browser,i rummaged through web and found some links:
I tried this link:Embedding a .NET WinForms Application in an Internet Browser Using WPF
,this works fine but the problem is that the end-user has to install dot net frame work for running the application.
I found another link here for running a WinForms Application Inside Web Browser,with Visual WebGui development framework.
Has anyone had any experience with WebGui?
Well, Visual WebGui is web over ASP.NET. Its developing experience is the same/similar to that of Windows Forms using the Visual WebGui designer integrated into Visual Studio. You do your code behind just the same as you would on Windows Forms and the WebGui runtime transforms it into HTML5/CSS/JS.
The efforts needed to convert your Windows Forms application to a equivialend Visual WebGui web application will depend on the (3rd party / .NET) components used in your Windows Forms application. The Visual WebGui API is farily similar to that of Windows Forms, so in some cases you can add a few references to WebGui specific assemblies and then to a search/replace for a couple of namespaces. There are of course some differences, as these are two different platforms, but the developing experience is quite similar to Windows Forms.
winforms is not web. Web is Web.
Web means HTML + something (usually JavaScript, CSS and probably jQuery or such).
1 - If you need a web application, and want to do it with .Net, create an ASP.Net Application.
2 - If you need a Windows application (Desktop), create a WPF application.
3 - If you need a Windows 8 "Metro" style application (a.k.a Windows Store App), create a WinRT XAML application.
4 - winforms is completely useless. Forget that.
If your customers don't want to install any version of the .Net Framework, your only option is #1.
A winforms application will NEVER be a web application, regardless of any hacks you do to make it run inside a web browser.
an XBAP (WPF Browser Application) is also NOT a web application. It's just a regular WPF client application that does not have it's own window.
Edit:
If you did things the right way (that is, maintaing separation of concerns and putting application logic in Controllers or ViewModels instead of the horrible code behind practices most winforms developers are generally used to), It should not be that hard to reuse your application logic and create a new application (web or otherwise) while maintaining the Data Access and Business Logic layers intact.
I think this question is very similar to this one:
Is it possible to convert a WinForm to a WebForm in .NET?
As mentioned before, the only way to run the application "as is" inside a browser will be through the use of some activex control and that would require IE + .NET Framework.
There are tools that you can use to automatically migrate the application to the Web, but there will always be some manual effort involved and it won't be the same as building the application from scratch as a web app.
In my limited experience with Visual WebGui, it is pretty cool technology. In simple terms, as I understand it, you can use the Windows Forms development IDE to create an HTML5-compliant ASP.NET client/server web application... not just a web site or page, with a look and feel very much like a Windows forms desktop application. It does this by converting Winforms controls to jquery code on the client side, and stores most of the executable code on the server side.
I've used it to create simple applications for testing purposes, and there are a few caveats. First, to create a "pretty" website, you need to rethink the Winforms layout to make it web-like, with headers, sidebars, etc. It's a different paradigm, and users expect certain things on a website. The good news is that this adjustment can often be done fairly easy by simply manipulating controls; i.e. a Panel control can become a container for a sidebar or header. You can also create "themes", which are like skins for the controls to modify the appearance.
Another consideration is that events for things like popup dialog boxes behave differently in a web environment. In Winforms program execution halts until the user clicks an "OK" button or something. Within Visual WebGui, all the execution happens on the server side; thus, program execution would continue without waiting for user input. This can be handled by creating a Form.Close handler for the popup box though. But these kinds of differences need to be kept in mind.
You also must consider object layout anomalies. Visual WebGui does a good job generally of mimicking the Winforms WYSIWYG benefit: Objects normally appear pretty close on the webpage to where you put them in the environment. But this isn't always the case; you need to play around with object padding, margins, etc. sometimes to get the right layout. Still it is often much easier than tediously changing spacing with CSS or div objects.
Thinfinity VirtualUI allows you to do so by adding a small line of code to your C# application so it can then be accessed from any OS and device via an HTML-able browser.
https://www.cybelesoft.com/thinfinity/virtualui/web-integration-for-windows-apps/
I've used VWG but it's not really an option anymore. One option not mentioned here is WiseJ, a proprietary framework which is still under active development and support in 2022. And it is fairly straightforward to convert a WinForms app to WiseJ, or begin using WiseJ like you would WinForms.
They are located here: https://wisej.com
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)
I wonder how to best develop a plugin framework where you can develop plugins with both C++/MFC and C#.
The Host Program is an existing program developed in native C++/MFC. To extend the functionality of this program, we have so far developed separate programs in C++/MFC and C# that run as separate applications or windows services. These programs are now communicating with the host application via files. This is obviously a rather clumsy method, and we therefore wish to bring them under a common plug-in framework.
Each program also has a separate management of settings. We therefore want each plugin to expand the settings window in the host application so that all settings can be managed in one place. How can we do that in a flexible and easy way?
(...) we therefore wish to bring them under a common plug-in framework. (...)
You can do that by creating a set of COM interfaces in a type library that you can wrap in a C++/MFC dll project. Then from either C++ or C# you can import this type library and create new COM classes that implement the predefined interfaces. Two disadvantages of these approach are: 1- That your main application will need to know the class IDs somehow to create instances of the COM classes. 2- Your plugins will need to be registered on the system or you will need to provide manifest files.
(...) We therefore want each plugin to expand the settings window in the
host application so that all settings can be managed in one place. (...)
This one is a bit more tricky, but you could try having a tab control with one tab for each plug-in, then pass the window handle of the corresponding tab to each plug-in during initialization, and then use that to place an ActiveX control on it. Creating ActiveX controls in MFC is well documented, and there is a sample project here for doing the same in C#: CSActiveX Sample