Raspberry PI – .NET Core GUI Winforms or WPF Possible ?

Since we have the .NET Core framework installed on the RPI.

Are we now able to build .NET GUI apps ?

The answer is not really as out of the box ?

But if you have MONO installed in your RPI it is possible.

Nothing to recompile even, see last example of this post Smile

There have been a few other attemps made as well.

Cross Platform WinForms, using ETO.Forms Library see here



SOLUTION :

You need to install the .NET NUGET Packages from here

dotnet add package Eto.Forms --version 2.5.11

dotnet add package Eto.Platform.Gtk --version 2.5.11

image

Once installed follow the code Examples here :

https://github.com/picoe/Eto

https://dotnetcoretutorials.com/2018/03/19/cross-platform-winforms-kinda/

dotnet new -i "Eto.Forms.Templates::*"

image

Next create a new ETO WinForms App

dotnet new etoapp -sln -m code -s

IMPORTANT : to have the .NET Core version 3.1 installed in your machine !

When you create a new ETO WinForms project make sure to reference to correct ETO Package Version

<ItemGroup>
  <PackageReference Include="Eto.Platform.Gtk" Version="2.4.1" />
</ItemGroup>

image

You can check the installed packages here

%UserProfile%\.nuget\packages


Build and Run the Windows version first to test if all is OK.

dotnet build "\WinformsTESTLinux.WinForms.csproj"

image

Now build the Linux Gtk version :

These are the project settings for a Gtk Form on Linux

 

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
	
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\WinformsTESTLinux\WinformsTESTLinux.csproj" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Eto.Platform.Gtk" Version="2.5.11" />
  </ItemGroup>
	
</Project>


Build the Gtk Form as follows (Don’t forget the specify the correct Runtime!!):

dotnet build "\WinformsTESTLinux.Gtk.csproj" -r linux-arm

Copy the binaries to your RPI and run it

image

Et voila Smile  Winking smile

We have built our first cross-platform Linux GUI using the ETO.forms

Another option is that you create a WRAPPER around the ZENITY GTK tool

Either using a .NET Core Console App or using PowerShell

I have created a PowerShell module to make life easier …

see here

see here



RASPBIAN GUI Design

Anyhow  if you are not into .NET Core cross-platform GUI development.

Here are a few tools that get you started Developing GUI apps on your RPI



ZENITY : see here for how to :

image

Zenity is available out of the box in Raspian.

If you are looking for an GUI IDE use this one.

it is simple and easy to use and it just does work all the way Smile

See here on how to interact with Zenity Widgets / Controls

image

See here for an SQLite DB in Zenity Example

image



GLADE :

sudo apt install glade

image

image



MONO :

Mono on RPI to run cross-platform .Net Gui’s

See here for how to.

Mono is not installed use this command

sudo apt-get install mono

or VB.net

sudo apt-get install mono-vbnc 

image

Create your WinForms App compile it and run it on your RPI, no re-compiling required!

image

This is a 1 to 1 compiled simple WinForms application on mono

clip_image002

Compile using the ANY CPU settings

image

Run it on you RPI

mono /home/pi/dotnet_projects/Test.exe

image

Also the button click event work Smile

Enjoy !!

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 )

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: