Windows Form based application layout/template - c#

I am very new to Windows form based application. I have Visual studio 2012 and want to create a windows application.
This question might be asked before but I was not able to find any clear answer, so I decided to post the question here..
I want to know that if there is a way to create a master form (or a kind of template) for my application having common controls and rest of the forms can inherit that, likewise we do in web-applications.
I found somewhere that instead of going with Windows Forms application, I should go with WPF application, if that is the case can somebody point me to a good article where I can find some info about it....

I really advise you to work with WPF, windows forms is dead since years. WPF is very flexible and you can do far more things than windows forms.
Here is how to implement Master-Page like behavior using WPF: Link.
Here are some WPF tutorial to start your journey:
http://www.wpftutorial.net/
http://www.tutorialspoint.com/wpf/
Learning WPF and XAML is great as it is very similar to most new technologies like Android (layouts), Xamarin (Forms), etc... So it is good technology to learn.

Related

ArcGIS web map in c# winform

I want to implement an ArcGIS web map in my winform C# application. I have found a bunch of resources for doing this in a WPF application, but nothing for the winform platform. I have an API-Key from ArcGIS and have already made a webmap.
Does anyone know if this is even possible or do I need to use WPF to do this? I have tried the GMap open source, and it does support some maps from ArcGIS, but I have not figured out how to add "custom" webmaps from a link. I would also need to add credentials to my example.
F.eks
Map.MapProvider = GMap.NET.MapProviders.ArcGIS_World_Street_MapProvider.Instance;
Edit,
Sadly it seems that the best solution is to implement a wpf controller into the winform application.
You can definitely use the Esri ArcGIS Runtime SDK to do this. Yes it is a WPF control, but that's no problem. You'll need to use the ElementHost to host WPF content inside the WinForms view, and this is fully supported but the runtime. Just be aware that WinForms uses software rendering, so you don't get as good performance as you would with a pure WPF, UWP or WinUI3 window.
So you'll just follow all the doc found on how to do it in WPF, then render that part of the view inside the ElementHost of your WinForms app.
WinForms Element host doc: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.integration.elementhost?view=net-5.0
Conceptual doc/examples of hosting WPF in WinForms:
https://learn.microsoft.com/en-us/dotnet/desktop/winforms/advanced/walkthrough-creating-new-wpf-content-on-windows-forms-at-design-time?view=netframeworkdesktop-4.8
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/walkthrough-hosting-a-wpf-composite-control-in-windows-forms?view=netframeworkdesktop-4.8
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/walkthrough-hosting-a-3-d-wpf-composite-control-in-windows-forms?view=netframeworkdesktop-4.8
/Morten Nielsen - Dev Lead (ArcGIS Runtime SDK for .NET)
If I understand correctly you want a world map, I don't know what you're planning on doing with it so if you just want to display a world map then I found a YouTube tutorial about this that might help,
https://www.youtube.com/watch?v=TxSJJfaAzKg
If you want an interactive map and arcgis does that for you then you can emulate a WPF control inside a winforms application,
https://www.youtube.com/watch?v=VfpzVDAJ1fE
Sorry if I'm only showing YouTube videos as sources instead of actual documentation, but at least it gets the job done.

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/

How can I port my Windows Phone game to a Silverlight thing that I can use on a webpage?

I'm confused about how to port my WP7 C# game to the web using Silverlight.
I know that code written in C# using the Windows Phone (add-in? plugin? other?) for Visual Studio makes a Silverlight app. But how can I embed my finished WP7 app in a webpage?
I've seen some things such as ExEn, SilverSprite, and XnaTouch {the page redirects to MonoGame}, but I'm confused if I even need something like this in order to make my game playable on the web. I've got a feeling the capability may even be embedded in Visual Studio. Is it even possible to do this without rewriting all the code?
Shortened version: How can I port my WP7 C# game to the web using Silverlight?
Create a new project in Visual Studio targeting Silverlight beside your WP7 project. Then if your existing code is structured nicely, you should be able to re-use most of your "back-end" code (the views, viewmodels people talk of). The best way to do this for files that are common is to add them as links to the new project, so you don't have to keep them both up to date - if there are small changes between versions you can use conditional compilation to do this.
You'll want to use some completely new classes for some things, such as probably the top level view. Some XAML (eg a UserControl definition) might be usable between both with changes, though some people will favour always creating different versions. Have a look at this extensive article on cross-platform SL/WPF/WP7 development.
What have you tried?
If you create a Silverlight application in Visual Studio, you should be able to include all your existing Views, ViewModels, resources and so on. I don't know if you'll be able to make a single project that both builds into a WP7 and a Silverlight application but I personally wouldn't bother trying.
You can't directly - there are missing runtime components and features that are only available to Windows Phone applications.
You can, however, reuse lots of code, especially C# - all XAML code, I beleive, you'll have to copy/paste from WP7 XAML to Silverlight XAML.

Should we learn Window Form before WPF?

Is there a learning curve? I want to pick up Windows Form but when reading many threads about WF vs WPF, I was totally persuaded by WPF. What should I do?
Just learn WPF and forget Windows Forms if you don't need it. Windows Forms and WPF are totally different so learning one of them does not really help with the other.
WPF - I learned windows forms first and it is difficult to switch my mind to MVVM mode now when I build UI's. I personally wish that WPF was my first love.
You do not need to know Windows Forms in order to learn WPF. If you are going to code in C# or VB.NET and are running on modern hardware, I would go with WPF.
There are no technical reasons why you'd want to learn Windows Forms before learning WPF. They are completely different technologies.
Unless you need to use Windows Forms to maintain an old application, stick with WPF.
It depends.
I assume you're working on a Windows application that must be installed on a client machine, Windows Forms and WPF would be good choices.
If you're starting an application from scratch, I would recommend WPF so focus on that.
If you have to maintain an existing application already written in Windows Forms, then you better learn Windows Forms.
Maybe it is not bad to first make a few application with Windows Form, that is classic way, and doing this you will not lose nothing because making application with Windows Form you just make classic application with standard UI. After this if you want that you application has better and nicer UI than go with WPF.
My personal opinion is the the learning curve on WPF is a lot steeper if you want to get all the benefits of using MVVM, so it could also depend on how your development team is set up, with how many people and how complex your solutions are. You can of course just use WPF with all code behind, but you might as well use WinForms if this is all you want to do.
Nope!
WPF is the latest trend. Winforms is not quite dead yet though...
If somebody wants to learn window application development. Starting from WPF will take him to the latest trend. Of course, Winform previous experience can be an advantage.

What is Silverlight's relationship -- if any -- to WPF?

I was working with a WPF application and I decided that the controls and graphics I wanted to display on the grid might look better if it was a silverlight component.
I thought this way because of all the cool silverlight controls that look very flash-like.
But now that I have gottem my Visual Studio 2010 set up with SIlverlight, it seems that every silverlight app I can make are ASP.NET in nature. It seems that instead of a cool GUI control to make, Silverlight is telling me that it is primarely a dataflow sort of application for the web.
What is the relationship, if any, between WPF and Silverlight. Can I or can I not put a silverlight control into my existing WPF application?
It's my understanding that Silverlight is like "WPF lite", and that in many ways they are almost the same thing but made for different purposes (desktop vs. web). If you want your wpf application to have a different look, you don't need to bring in any other controls from silverlight, because you can simply re-style or re-template them to suit your needs (which you can also do in silverlight). But you can't simply use silverlight controls in wpf because they're compiled to run on different runtimes.
Silverlight does have a number of un-official controls in the silverlight toolkit which are not included in wpf or the wpf toolkit. They are open source, and if you really want, you could port them to wpf, especially since the code is very similar to wpf.
Silverlight is essentially a subset of WPF that is used to create web-based applications.
You might be able to jump through some hoops to get a limited Silverlight application running in WPF, but I doubt it would be worth it...
I know others may point out that SL is WPF lite.
But hope you find out they are different frameworks at least right now though they share XAML, and a similar model.
Not sure if in the future they become the same, but keep the differences in mind is critical at this moment. :)
We know DevExpress is now shipping the same code base of their components for WPF and SL, but that does come after putting a lot of efforts.
http://community.devexpress.com/blogs/ctodx/archive/2010/04/20/merging-our-silverlight-and-wpf-ui-controls.aspx

Categories

Resources