A Cross Platform .NET UI Framework – Hello World in Avalonia UI



Ever wanted to bring your WPF or UWP application across platforms. What if you could ship your same app built on familiar WPF designs to MacOS, Linux and even Android and iOS? Avalonia UI is a framework built on top of the new cross platform capabilities of .NET with large amounts of inspiration taken from WPF.

The framework is currently in beta and not necessarily something you’d want to ship in a major project yet. But for creating developer tools or just experimenting it’s a ton of fun!

We’re going to explore the basic’s of Avalonia by creating a simple project that can great people by name. We’ll add a TextBlock, TextBox and Button. The TextBlock will display a greeting using the name entered into the TextBox when you click the button. This will give us a way to explore the basics of writing a UI in XAML, take advantage of the Data Binding capabilities offered and play with the ability to tie your XAML and code behind together with events.

You can find Avalonia on GitHub or on their website.

Some troubleshooting:
`dotnet install -i Avalonia.Templates.NetCore` is the recommended command for installing the Avalonia templates. `install` is not a command on dotnet. You can use `dotnet new -i Avalonia.Templates.NetCore` instead.

Discord:

Nguồn: https://hqclix.net/

Xem thêm bài viết khác: https://hqclix.net/game/

All Comments

  • Thank you for sharing! I used this great video to get a first look into Avalonia.
    After watching I created my first small Avalonia Demo app using Dotnet Core on Linux. In my code I used a Command="{Binding OnClickCommand}" in the Button properties and added the corresponding method to my DemoModelView.cs.

    Edit: I just realized that this video is 2 years old, but still valid and perfect.

    Peter Gloor June 23, 2020 8:44 pm Reply
  • You're good! Thanks for this. You're doing a great job. I learned some stuff from you.

    Sorin Ciaia June 23, 2020 8:44 pm Reply
  • Cheers for the video mate! Really helpful for getting started.

    A Big Pickle June 23, 2020 8:44 pm Reply
  • Fantastic video! I am a novice programmer with WPF. Not only was this a great tutorial, you actually helped clarify many questions I had with binding.

    Jason Garner June 23, 2020 8:44 pm Reply
  • I really enjoyed this video btw! I'm curious, do you know if there's any way to generate standalone .exe / .app bundles with avalonia? I love working in .net core when i have to do mac stuff, and while it's super convenient, having to either run the application via dotnet run or generating a standalone that has to be run with ./myApp in terminal seems a bit clunky.

    I kind of cringe at this thought, but is the only answer to create like, a cocoa app that adds the dll output as a dependency and just immediately diverts to running a process that calls dotnet run myApp? Seems a big janky just to get a .app bundle.

    Everything is unnecessarily complicated on macs, this is why I stick to windows for development x.x

    stropheum June 23, 2020 8:44 pm Reply
  • I just found avalonia today! I had a cross platform .NET core command line tool that i wrote for windows and mac, and got a request from the boys who make the decisions to make it a GUI app. I was struggling, trying to hack together a xamarin app and port my code to .NET standard. Huge PITA. Came across this and I am so stoked

    stropheum June 23, 2020 8:44 pm Reply
  • One thing I can't get fixed on my workstation is the Intellisense for xaml file. No error-detection or even auto complete.

    S R June 23, 2020 8:44 pm Reply
  • Thanks for shared!!!

    俞俞 June 23, 2020 8:44 pm Reply
  • My best moment is at 17:03. Thanks for video, very helpful.

    Brtk :) June 23, 2020 8:44 pm Reply
  • Sick!!

    Carlos Schipper June 23, 2020 8:44 pm Reply
  • Excellent,. Is possible to use in Xamarin Forms too?

    João Alves June 23, 2020 8:44 pm Reply
  • Sorry dude, I deleted my comment before I saw that you answered it. Anyway, I already found a limitation with Avalonia compared to WPF, it apparently doesn't have DataGrids.

    CodeBit June 23, 2020 8:44 pm Reply
  • Good stuff! Thanks. Let’s start .net core hardcore!

    ERPro ERPro June 23, 2020 8:44 pm Reply

Leave a Reply

Your email address will not be published. Required fields are marked *