Giter Site home page Giter Site logo

brminnick / hellomauimarkup Goto Github PK

View Code? Open in Web Editor NEW
20.0 4.0 1.0 165 KB

An iOS, Android, macOS + Windows app built using .NET MAUI, demonstrating how to use the .NET MAUI Markup Community Toolkit

Home Page: https://github.com/communitytoolkit/maui.markup

License: MIT License

C# 100.00%
ios android windows macos catalyst maccatalyst dotnet net6 winui hacktoberfest

hellomauimarkup's Introduction

.NET MAUI

HelloMauiMarkup

The .NET MAUI Markup Community Toolkit is a collection of Fluent C# Extension Methods that allows developers to continue architecting their apps using MVVM, Bindings, Resource Dictionaries, etc., without the need for XAML.

.NET MAUI Markup Community Toolkit

This specific example uses CommunityToolkit.Maui.Markup and CommunityToolkit.Maui.Markup.GridRowsColumns

Add Markup Namespace

At the top of MainPage.cs, add the following using static

using static CommunityToolkit.Maui.Markup.GridRowsColumns;

Add enum Row

In MainPage.cs, add an enum to define the Grid rows:

enum Row { HelloWorld, Welcome, Count, ClickMeButton, Image }

Define Grid

In the constructor of MainPage.cs, define the Content as a Grid

Content = new Grid
{
    RowSpacing = 25,

    Padding = Device.RuntimePlatform switch
    {
        Device.iOS => new Thickness(30, 60, 30, 30),
        _ => new Thickness(30)
    },

    RowDefinitions = Rows.Define(
        (Row.HelloWorld, Auto),
        (Row.Welcome, Auto),
        (Row.Count, Auto),
        (Row.ClickMeButton, Auto),
        (Row.Image, Auto)),

    Children =
    {
        new Label { Text = "Hello World" }
            .Row(Row.HelloWorld).Font(size: 32)
            .CenterHorizontal().TextCenter(),

        new Label { Text = "Welcome to .NET MAUI Markup Community Toolkit Sample" }
            .Row(Row.Welcome).Font(size: 18)
            .CenterHorizontal().TextCenter(),

        new HorizontalStackLayout
        {
            new Label { Text = "Current Count: " }
                .Font(bold: true)
                .FillHorizontal().TextEnd(),

            new Label()
                .Font(bold: true)
                .FillHorizontal().TextStart()
                .Bind<Label, int, string>(Label.TextProperty, nameof(MainViewModel.ClickCount), convert: count => count.ToString())

        }.Row(Row.Count).CenterHorizontal(),

        new Button { Text = "Click Me" }
            .Row(Row.ClickMeButton)
            .Font(bold: true)
            .CenterHorizontal()
            .BindCommand(nameof(ViewModel.ClickMeButtonCommand)),

        new Image { Source = "dotnet_bot.png", WidthRequest = 250, HeightRequest = 310 }
            .Row(Row.Image)
            .CenterHorizontal()
    }
}

hellomauimarkup's People

Contributors

brminnick avatar danielmonettelli avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

codemonkey85

hellomauimarkup's Issues

Unable to load DLL 'Microsoft.ui.xaml.dll' or one of its dependencies

Describe the bug
Unable to load DLL 'Microsoft.ui.xaml.dll' or one of its dependencies

To Reproduce
dotnet build ./src -t:Run -f:net6.0-windows10.0.19041.0

Expected behavior
No Error.

Exception
Unhandled exception. System.DllNotFoundException: Unable to load DLL 'Microsoft.ui.xaml.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
at HelloMauiMarkup.WinUI.Program.XamlCheckProcessRequirements()

Documentation Discrepancy - Root Grid Padding iOS/Android

Seems the code is now using On().SetUseSafeArea(shouldUseSafeArea) in the BaseContentPage but in the README you're using:
Padding = Device.RuntimePlatform switch
{
Device.iOS => new Thickness(30, 60, 30, 30),
_ => new Thickness(30)
},
Just a heads up.

Fails to run on Windows 10

Describe the bug
Using Visual Studio 2022 preview latest version this program will compile clean however it will never bring up the UI. When I try to start the .exe it spins for a couple of seconds and then stops. The application never shows up in task manager. I'm running Windows 10 with all of the latest patches installed.

To Reproduce
Using Visual Studio 2022 clone this repository and attempt to debug for Windows

Expected behavior
I would expect to see the .net robot in the UI and have the count button.

Screenshots
No UI ever appears

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows 10 with all of the latest patches
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
I'm new to both C# and .NET MAUI so I'm not sure where to start troubleshooting a problem like this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.