Home > C# Coding, Software, Uncategorized > C# WPF programming / my other side

C# WPF programming / my other side

As well as antennas and radio I am also quite keen on coding/programming in C# for mainly Windows applications.  I started writing programs in the 1980’s using Commodore BASIC and moved on from there.  A few years ago (about 10) I picked up where I left off and started using Visual C# in Visual Studio.  Funnily, although I started out with BASIC, I just couldn’t get on with Visual Basic – a feeling I hear echoed amongst many of my friends and contacts – so I gave C# a go.

I started like most with the standard “Hello World” program:-

  • static void Main(string[] args)
  • {
    • Console.Writeline(“Hello World”);
  •  {

and then moved on to Windows Forms programming which was quite easy and self explanatory. Using Windows XP and Windows 7 (never touched Vista) Windows Forms were great and I created many small but useful programs, some of which I published through the Microsoft app store.  Then with the advent of Windows 8 Windows Store apps were more for the Windows Phone which, unfortunately was too late to the already flooded smartphone market and was later withdrawn.  Also around this time, I moved from using Windows Forms to using WPF in Visual Studio 2012.  What a difference! Gone were the square regimental blocks used in WinForms and suddenly transition between pages and windows was much more fluid and reasonable animation was possible.  However, it did mean also having to learn XAML.

WinFormsSample Windows Forms layout in VS2017

WPFSample.JPG WPF layout in VS2017, note the XAML beneath the design screen.

Then Windows 10 happened.  With Windows 10 the Windows Store became more difficult -apps had to be written in UWP(Universal Windows Protocol) format.  An absolute nightmare for most developers.  This was a much stricter protocol with limitations on what was allowed and , due to the many different form factors including PC Desktop, tablet, Phone, etc, it need to be able to resize without truncation.  So what now for all of us who had been happily writing software in WinForms or WPF?  Did this mean that we would have to learn UWP coding?

UWPSample UWP Layout in VS2017

Not at all it turns out.  Thankfully, if you upgrade to Visual Studio 2019 (even the Community Version) you can write your desktop apps using WPF in order to tweak them and perfect them ready for uploading to the Windows Store.  However, before you can you must first right click on the solution and add new project.  This should be a UWP blank app. There is no need to write any code for this project, just right click on the project and associate it with the app you have created in WPF.  Once you have done this right click on the UWP project that you have added and scroll down to publish and then create Windows Store App Package.  This will create a package that can be uploaded to the Windows Store (.appxupload, appxbundle, etc).

Of course, in all samples above, the result is the same, the message “Hello World” is displayed in the screen. However, in the first, console project the command to do so is

“Console.Writeline(“Hello World”);

in the Windows Form and WPF the command is

“MessageBox.Show(“Hello World”);

and in the UWP app the command is

“MessageDialog msg = new MessageDialog(“Hello World”);
msg.ShowAsync();”

Showing how each of the different packages differ in their command format.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: