How can I attach a Silverlight OOB to a Winforms panel? - c#

Summary:
I want the prettiness of Silverlight/WPF in part of my current Winforms application. The application can only have access to the full .NET Framework 2.0, no more and no less. The only possibility I can think of is a Silverlight OOB application that utilizes Com+ Automation but I can't figure out how to attach the Silverlight application to a panel within the parent Winforms application.
Details:
I currently have a winforms application, and want to take advantage of the improved GUI features in WPF but to many of my users are still running .Net Framework 2.0 and refuse to update to 3+. So WPF is not an option for me.
I know Silverlight is just a subset of WPF, but it has most of the features I'm looking for and only requires the Silverlight plug-in. I've read about Silverlight 4's Com+ Automation, which would give me access to the full desktop .Net Framework 2.0 (which I need). In order for Com+ Automation to work in Silverlight I need elevated trust and the only way I can find to gain elevated trust is to make my Silverlight application Out-Of-Browser (OOB).
My problem is that the OOB application seems to run in its own container window and I need the Silverlight application embedded inside a panel in my Winforms application. My Winforms application does not need to communicate with the Silverlight application and vice-versa, this is purely to have everything contained and displayed in one window.
If there is another way to get my desired result that I have not thought of feel free to suggest it.

The best option is to host the Silverlight content within a WebBrowser Control. This will allow your Silverlight content to run "inside" your windows forms application.
The COM automation won't help for embedded silverlight INTO a Windows Forms application. It's really intended for using COM from within Silverlight, not the other way around.

Related

C# windows application run in MacOS [duplicate]

This question already has answers here:
Porting WinForms Application to Mac OS
(2 answers)
Closed 2 years ago.
I'm just new in C# Windows Form. Now I have a project that Uploads a txt file and output into a PDF file. Now I need to use C# windows form for this but I'm just curious if I develop this using C# Windows form will I be able to install the application on a MacOS environment and use it as how I can use it on windows? Are there any consideration needed? Like do I need to install a certain package just to make it work in Mac or vice versa?
I'm just new in C# Windows Form.
Hi!
Now I have a project that Uploads a txt file and output into a PDF file.
Go on...
Now I need to use C# windows form for this
No, you don't need to use WinForms to simply upload a text file and download a PDF.
but I'm just curious if I develop this using C# Windows form will I be able to install the application on a MacOS environment and use it as how I can use it on windows?
No, you cannot. WinForms is tightly coupled to the Microsoft Windows operating-system (the biggest clue is in the name: Windows Forms. WinForms' is a thin wrapper around Windows' default windowed controls and widgets (also called User32 and Common Controls) as well as OLE, COM + ActiveX, and other Windows-centric APIs.
There are attempts to make a subset of WinForms work on other operating systems, but because WinForms is not natively cross-platform you won't have things like support for macOS's main menu and your users will be able to tell that your program doesn't look and feel like a native program.
Are there any consideration needed? Like do I need to install a certain package just to make it work in Mac or vice versa?
No, it won't work.
Alternative Approaches:
Make your application using WinForms System.Windows.Forms and make it available to macOS users through some form of application remoting:
Run it on a Windows box accessed using macOS' Remote Desktop app.
Run it on a Windows box accessed using a browser-based RDP gateway.
Run it in a Windows virtual-machine running on an Apple Mac (Parallels Fusion, VirtualBox, etc).
Using only natively supported cross-platform features in .NET Core:
Make your application with a built-in http://localhost ASP.NET web-server that hosts a GUI web-application accessed with a web-browser that interacts with the rest of your application code.
Make a command-line only application.
Make a text-mode GUI application using a library like ncurses for .NET.
Make a platform-specific GUI while still sharing the rest of your application code (e.g. using Xamarin to use Cocoa from .NET, use WinForms or WPF on Windows, GTK# for Linux/BSD, etc).

can .net windows forms project and .net UWP project be merged?

I have a GUI windows form app written in .NET .
And I have a new .NET UWP app that has UWP camera and UWP sockets.
Can I port the UWP camera and UWP sockets code into the .NET Windows form app project?
(If I went the other way, it probably will take much longer to port the Windows forms GUI into a UWP GUI.)
WinForm project can use most new Windows 10 API designed for UWP. Check this post.
If went the other way, you need to port bit by bit of the existing GUI, so it all depends how complex your WinForm GUI is.
The first challenge is you are using XAML, another language instead of C# to write UWP UI.
Some WinForm controls you are using just do not have a UWP counterpart, you need to turn to the community to check if there are alternatives that are freely available l, or purchase proprietary product, or write your own control.
No. WinForm and UWP projects are very different. UWP are compiled to native code and WinForm are compiled to IL that are then run by the CLR. Microsoft is currently working on the ability to put a UWP control inside a WinForm application. You can check it out here.

Style my .Net desktop application GUI with Silverlight/windows phone-style controls

I am writing my first vb.net application ( But I will tag c# here as well, as I am sure even a c# person can answer this with the similar .net implementation).
Short Description of my Applicaiton:
My desktop application will run on win platform only, using vb.net, it is a simple internet cafe management software, with a server gui running on server, and a client gui running on workstations, both communicating with TCP/IP to allocate time to customers, and the server storing some data in either xml files ( for human operators login info e.g) or in a small database. Nothing complicated.
What I would like to do:
I'd like to have a "sexy" look, i.e. either silverlight look or win7 phone look, yet this is a desktop application. I'd like to use CSS but its entirely optional, if there is a simple way to have my controls look like below without CSS thats fine with me.
What I have tried
I have looked into just doing a silverlight out of browser app, but as I am new to .net, and even though I have read up as many articles about using silverlight5 out of browser, I don't want to be caught down the road when I want to implement a feature and realize "Oh silverlight out of box doesnt support that".
So my question is , how do I implement one of the new looks in the picture in my desktop vb app?
You should look at using WPF for your application instead of using WinForms.
WPF (Windows Presentation Foundations) is a platform which works same way as silverlight but on desktop (as far as you need to be aware now.) Silverlight is a cut down version of WPF so WPF will give you a lot more controls and a lot more control over the program.
WPF uses XAML to draw up the UI and it holds the code in the source code file associated to the xaml file. If you have experience using Silverlight you should easily be able to make programs with WPF.
WPF is really powerful and gives you access to all the styling that is possible on Silverlight. WinForms is more so restricted which makes it harder to abandon the consistent Windows look and make your own intuitive and innovative UI.
Hope it helps!
Here are some tutorials if you are interested:
WPF Tutorials
Here is an example WPF desktop app (exact same look as achievable with Silverlight)
You can use wpf with Mahapps Metro : http://mahapps.com/MahApps.Metro/

Developing a simple Windows system tray desktop app to consume a .NET web service

I'm required to develop a simple Windows system tray desktop app to consume a .NET web service but I'm proficient in PHP, and I have little background in desktop applications. What platform would you advise me to use, preferably with a very low learning curve?
The system tray app will show (in a context menu) a counter of notifications of new events as received from the .NET web service; and will also write all the event logs into a text file.
I'm already thinking Adobe AIR or C# .NET but I want to know if there are any better options that I can learn quickly to develop the app.
Keep it all in .NET. You can easily write a Windows Forms application to display a tray icon and display notifications as and when something happens in the web service (you'd probably need a timer to do the polling).
There are plenty of articles around that will show you how to do this. Here's one to get you started:
http://www.codeproject.com/Articles/290013/Formless-System-Tray-Application
I assume that you have to use WPF and MVVM so it is going to be really awesome app.
And the best example I found is that one
WPF NotifyIcon
http://www.codeproject.com/Articles/36468/WPF-NotifyIcon

Windows application using Silverlight

I want to develop a windows based application in silverlight. I went through many articles and every where I found that "Silverlight is for web based application". I don't know whether I am wrong or right, as my superiors told me that in Silverlight5 we can develop Windows based application. Can any body help me to give a clue for how to start. Any help would be highly appreciated.
Thanks in advance
If you mean a Windows based application which can connect with internet you go for Out of Browser application which silverlight supports but if you want simple plain desktop application, there is no point in using Silverlight, WPF would be the right choice in that case.
Look at this article for building an out of browser app using Silverlight.
Silverlight specializes in building rich UI based Web applications and WPF is best for making UI rich applications for Desktop.
You can run silverlight apps "Out Of Browser", its just a setting in the config. Here's a video with more info: http://www.silverlight.net/learn/videos/all/out-of-browser-experiences/
silverlight is a web-based technology that runs on the client machine. it is, basically, Microsoft's version of Flash.
Now, that being said, you CAN write silverlight apps that run out of the browser. but, they are not "really" windows apps. silverlight is a sub-set of WPF. However, you can also make WPF apps that run in a browser. Confused yet?
The bottom line is that WPF is for desktop apps and is full-featured with access to the machine resources.
while silverlight is a light-weight version of WPF that is intended to be run in a browser, similar to flash. it does not have all the features of a full desktop application due to security model and that sort of thing.
Both have elements that cross into the domain of the other.
Like all good things, the answer is "it depends on what you're trying to do". If you want an application that can run inside the browser, outside the browser, plus on Windows and Mac then Silverlight is the answer. You also get for free/are restricted by a security sandbox; you can get around this sandbox by requiring additional permissions from the user. If you're trying to do something that requires multiple monitor support, access to COM objects, stroke/pen/stylus input, 3D hardware acceleration, or access to a large local file store then WPF is probably the better answer. Silverlight out of browser applications also have a nice "phone home" feature that will automatically download updates; WPF requires you to roll this by hand.
Some folks have mention XBAPs (running WPF inside of a browser). Stay away from this error prone steaming pile of stuff. It's good for demoware, but is not something which you'd want to support.
You heard right.
This is called "out of browser":
Silverlight-based applications typically run within Web pages, but you can enable users to install them from the Web and run them outside the browser.

Categories

Resources