├── MauiShellApp
├── Resources
│ ├── icon_about.png
│ ├── icon_feed.png
│ ├── xamarin_logo.png
│ ├── Fonts
│ │ └── OpenSans-Regular.ttf
│ ├── appicon.svg
│ ├── appiconfg.svg
│ └── Images
│ │ └── dotnet_bot.svg
├── Properties
│ └── launchSettings.json
├── Models
│ └── Item.cs
├── Views
│ ├── AboutPage.xaml.cs
│ ├── ItemDetailPage.xaml.cs
│ ├── LoginPage.xaml.cs
│ ├── NewItemPage.xaml.cs
│ ├── ItemsPage.xaml.cs
│ ├── ItemDetailPage.xaml
│ ├── LoginPage.xaml
│ ├── NewItemPage.xaml
│ ├── ItemsPage.xaml
│ └── AboutPage.xaml
├── Platforms
│ ├── Android
│ │ ├── Resources
│ │ │ └── values
│ │ │ │ └── colors.xml
│ │ ├── MainApplication.cs
│ │ ├── AndroidManifest.xml
│ │ └── MainActivity.cs
│ ├── iOS
│ │ ├── AppDelegate.cs
│ │ ├── Program.cs
│ │ └── Info.plist
│ ├── MacCatalyst
│ │ ├── AppDelegate.cs
│ │ ├── Program.cs
│ │ └── Info.plist
│ └── Windows
│ │ ├── App.xaml
│ │ ├── app.manifest
│ │ ├── App.xaml.cs
│ │ └── Package.appxmanifest
├── App.xaml.cs
├── Services
│ ├── IDataStore.cs
│ └── MockDataStore.cs
├── MauiProgram.cs
├── ViewModels
│ ├── AboutViewModel.cs
│ ├── LoginViewModel.cs
│ ├── ItemDetailViewModel.cs
│ ├── BaseViewModel.cs
│ ├── NewItemViewModel.cs
│ └── ItemsViewModel.cs
├── MainPage.xaml.cs
├── AppShell.xaml.cs
├── App.xaml
├── MainPage.xaml
├── MauiShellApp.csproj
└── AppShell.xaml
├── MauiShellApp.sln
└── .gitignore
/MauiShellApp/Resources/icon_about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jfversluis/MauiShellAppTemplate/HEAD/MauiShellApp/Resources/icon_about.png
--------------------------------------------------------------------------------
/MauiShellApp/Resources/icon_feed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jfversluis/MauiShellAppTemplate/HEAD/MauiShellApp/Resources/icon_feed.png
--------------------------------------------------------------------------------
/MauiShellApp/Resources/xamarin_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jfversluis/MauiShellAppTemplate/HEAD/MauiShellApp/Resources/xamarin_logo.png
--------------------------------------------------------------------------------
/MauiShellApp/Resources/Fonts/OpenSans-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jfversluis/MauiShellAppTemplate/HEAD/MauiShellApp/Resources/Fonts/OpenSans-Regular.ttf
--------------------------------------------------------------------------------
/MauiShellApp/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "Windows Machine": {
4 | "commandName": "MsixPackage",
5 | "nativeDebugging": false
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/MauiShellApp/Models/Item.cs:
--------------------------------------------------------------------------------
1 | namespace MauiShellApp.Models;
2 |
3 | public class Item
4 | {
5 | public string Id { get; set; }
6 | public string Text { get; set; }
7 | public string Description { get; set; }
8 | }
--------------------------------------------------------------------------------
/MauiShellApp/Views/AboutPage.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace MauiShellApp.Views;
2 |
3 | public partial class AboutPage : ContentPage
4 | {
5 | public AboutPage()
6 | {
7 | InitializeComponent();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/MauiShellApp/Resources/appicon.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/Android/Resources/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #512BD4
4 | #2B0B98
5 | #2B0B98
6 |
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/iOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 |
3 | namespace MauiShellApp;
4 |
5 | [Register("AppDelegate")]
6 | public class AppDelegate : MauiUIApplicationDelegate
7 | {
8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9 | }
10 |
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/MacCatalyst/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 |
3 | namespace MauiShellApp;
4 |
5 | [Register("AppDelegate")]
6 | public class AppDelegate : MauiUIApplicationDelegate
7 | {
8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9 | }
10 |
--------------------------------------------------------------------------------
/MauiShellApp/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using MauiShellApp.Services;
2 |
3 | namespace MauiShellApp;
4 |
5 | public partial class App : Application
6 | {
7 | public App()
8 | {
9 | InitializeComponent();
10 |
11 | DependencyService.Register();
12 | MainPage = new AppShell();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/MauiShellApp/Views/ItemDetailPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using MauiShellApp.ViewModels;
2 |
3 | namespace MauiShellApp.Views;
4 |
5 | public partial class ItemDetailPage : ContentPage
6 | {
7 | public ItemDetailPage()
8 | {
9 | InitializeComponent();
10 | BindingContext = new ItemDetailViewModel();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/MauiShellApp/Services/IDataStore.cs:
--------------------------------------------------------------------------------
1 | namespace MauiShellApp.Services;
2 | public interface IDataStore
3 | {
4 | Task AddItemAsync(T item);
5 | Task UpdateItemAsync(T item);
6 | Task DeleteItemAsync(string id);
7 | Task GetItemAsync(string id);
8 | Task> GetItemsAsync(bool forceRefresh = false);
9 | }
10 |
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/Windows/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/MauiShellApp/Views/LoginPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using MauiShellApp.ViewModels;
2 |
3 | namespace MauiShellApp.Views;
4 |
5 | [XamlCompilation(XamlCompilationOptions.Compile)]
6 | public partial class LoginPage : ContentPage
7 | {
8 | public LoginPage()
9 | {
10 | InitializeComponent();
11 | this.BindingContext = new LoginViewModel();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/MauiShellApp/Views/NewItemPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using MauiShellApp.Models;
2 | using MauiShellApp.ViewModels;
3 |
4 | namespace MauiShellApp.Views;
5 |
6 | public partial class NewItemPage : ContentPage
7 | {
8 | public Item Item { get; set; }
9 |
10 | public NewItemPage()
11 | {
12 | InitializeComponent();
13 | BindingContext = new NewItemViewModel();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/MauiShellApp/MauiProgram.cs:
--------------------------------------------------------------------------------
1 | namespace MauiShellApp;
2 |
3 | public static class MauiProgram
4 | {
5 | public static MauiApp CreateMauiApp()
6 | {
7 | var builder = MauiApp.CreateBuilder();
8 | builder
9 | .UseMauiApp()
10 | .ConfigureFonts(fonts =>
11 | {
12 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
13 | });
14 |
15 | return builder.Build();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/Android/MainApplication.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Runtime;
3 |
4 | namespace MauiShellApp;
5 |
6 | [Application]
7 | public class MainApplication : MauiApplication
8 | {
9 | public MainApplication(IntPtr handle, JniHandleOwnership ownership)
10 | : base(handle, ownership)
11 | {
12 | }
13 |
14 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
15 | }
16 |
--------------------------------------------------------------------------------
/MauiShellApp/ViewModels/AboutViewModel.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Input;
2 |
3 | namespace MauiShellApp.ViewModels;
4 |
5 | public class AboutViewModel : BaseViewModel
6 | {
7 | public AboutViewModel()
8 | {
9 | Title = "About";
10 | OpenWebCommand = new Command(async () => await Browser.OpenAsync("https://aka.ms/xamarin-quickstart"));
11 | }
12 |
13 | public ICommand OpenWebCommand { get; }
14 | }
15 |
--------------------------------------------------------------------------------
/MauiShellApp/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace MauiShellApp;
2 |
3 | public partial class MainPage : ContentPage
4 | {
5 | int count = 0;
6 |
7 | public MainPage()
8 | {
9 | InitializeComponent();
10 | }
11 |
12 | private void OnCounterClicked(object sender, EventArgs e)
13 | {
14 | count++;
15 | CounterLabel.Text = $"Current count: {count}";
16 |
17 | SemanticScreenReader.Announce(CounterLabel.Text);
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/iOS/Program.cs:
--------------------------------------------------------------------------------
1 | using ObjCRuntime;
2 | using UIKit;
3 |
4 | namespace MauiShellApp;
5 |
6 | public class Program
7 | {
8 | // This is the main entry point of the application.
9 | static void Main(string[] args)
10 | {
11 | // if you want to use a different Application Delegate class from "AppDelegate"
12 | // you can specify it here.
13 | UIApplication.Main(args, null, typeof(AppDelegate));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/MacCatalyst/Program.cs:
--------------------------------------------------------------------------------
1 | using ObjCRuntime;
2 | using UIKit;
3 |
4 | namespace MauiShellApp;
5 |
6 | public class Program
7 | {
8 | // This is the main entry point of the application.
9 | static void Main(string[] args)
10 | {
11 | // if you want to use a different Application Delegate class from "AppDelegate"
12 | // you can specify it here.
13 | UIApplication.Main(args, null, typeof(AppDelegate));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/MauiShellApp/Views/ItemsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using MauiShellApp.ViewModels;
2 |
3 | namespace MauiShellApp.Views;
4 |
5 | public partial class ItemsPage : ContentPage
6 | {
7 | ItemsViewModel _viewModel;
8 |
9 | public ItemsPage()
10 | {
11 | InitializeComponent();
12 |
13 | BindingContext = _viewModel = new ItemsViewModel();
14 | }
15 |
16 | protected override void OnAppearing()
17 | {
18 | base.OnAppearing();
19 | _viewModel.OnAppearing();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/MauiShellApp/AppShell.xaml.cs:
--------------------------------------------------------------------------------
1 | using MauiShellApp.Views;
2 |
3 | namespace MauiShellApp;
4 |
5 | public partial class AppShell : Shell
6 | {
7 | public AppShell()
8 | {
9 | InitializeComponent();
10 | Routing.RegisterRoute(nameof(ItemDetailPage), typeof(ItemDetailPage));
11 | Routing.RegisterRoute(nameof(NewItemPage), typeof(NewItemPage));
12 | }
13 |
14 | private async void OnMenuItemClicked(object sender, EventArgs e)
15 | {
16 | await Shell.Current.GoToAsync("//LoginPage");
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/MauiShellApp/ViewModels/LoginViewModel.cs:
--------------------------------------------------------------------------------
1 | using MauiShellApp.Views;
2 |
3 | namespace MauiShellApp.ViewModels;
4 |
5 | public class LoginViewModel : BaseViewModel
6 | {
7 | public Command LoginCommand { get; }
8 |
9 | public LoginViewModel()
10 | {
11 | LoginCommand = new Command(OnLoginClicked);
12 | }
13 |
14 | private async void OnLoginClicked(object obj)
15 | {
16 | // Prefixing with `//` switches to a different navigation stack instead of pushing to the active one
17 | await Shell.Current.GoToAsync($"//{nameof(AboutPage)}");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/MauiShellApp/Views/ItemDetailPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/MauiShellApp/Views/LoginPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/Windows/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 | true/PM
12 | PerMonitorV2, PerMonitor
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/Android/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Content.PM;
3 | using Android.OS;
4 |
5 | namespace MauiShellApp;
6 |
7 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)]
8 | public class MainActivity : MauiAppCompatActivity
9 | {
10 | protected override void OnCreate(Bundle savedInstanceState)
11 | {
12 | base.OnCreate(savedInstanceState);
13 | Platform.Init(this, savedInstanceState);
14 | }
15 |
16 | public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
17 | {
18 | Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
19 |
20 | base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/Windows/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.UI.Xaml;
2 |
3 | // To learn more about WinUI, the WinUI project structure,
4 | // and more about our project templates, see: http://aka.ms/winui-project-info.
5 |
6 | namespace MauiShellApp.WinUI;
7 |
8 | ///
9 | /// Provides application-specific behavior to supplement the default Application class.
10 | ///
11 | public partial class App : MauiWinUIApplication
12 | {
13 | ///
14 | /// Initializes the singleton application object. This is the first line of authored code
15 | /// executed, and as such is the logical equivalent of main() or WinMain().
16 | ///
17 | public App()
18 | {
19 | this.InitializeComponent();
20 | }
21 |
22 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
23 |
24 | protected override void OnLaunched(LaunchActivatedEventArgs args)
25 | {
26 | base.OnLaunched(args);
27 |
28 | Platform.OnLaunched(args);
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/MacCatalyst/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UIDeviceFamily
6 |
7 | 1
8 | 2
9 |
10 | UIRequiredDeviceCapabilities
11 |
12 | arm64
13 |
14 | UISupportedInterfaceOrientations
15 |
16 | UIInterfaceOrientationPortrait
17 | UIInterfaceOrientationLandscapeLeft
18 | UIInterfaceOrientationLandscapeRight
19 |
20 | UISupportedInterfaceOrientations~ipad
21 |
22 | UIInterfaceOrientationPortrait
23 | UIInterfaceOrientationPortraitUpsideDown
24 | UIInterfaceOrientationLandscapeLeft
25 | UIInterfaceOrientationLandscapeRight
26 |
27 | XSAppIconAssets
28 | Assets.xcassets/appicon.appiconset
29 |
30 |
31 |
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | LSRequiresIPhoneOS
6 |
7 | UIDeviceFamily
8 |
9 | 1
10 | 2
11 |
12 | UIRequiredDeviceCapabilities
13 |
14 | arm64
15 |
16 | UISupportedInterfaceOrientations
17 |
18 | UIInterfaceOrientationPortrait
19 | UIInterfaceOrientationLandscapeLeft
20 | UIInterfaceOrientationLandscapeRight
21 |
22 | UISupportedInterfaceOrientations~ipad
23 |
24 | UIInterfaceOrientationPortrait
25 | UIInterfaceOrientationPortraitUpsideDown
26 | UIInterfaceOrientationLandscapeLeft
27 | UIInterfaceOrientationLandscapeRight
28 |
29 | XSAppIconAssets
30 | Assets.xcassets/appicon.appiconset
31 |
32 |
33 |
--------------------------------------------------------------------------------
/MauiShellApp/Views/NewItemPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/MauiShellApp/ViewModels/ItemDetailViewModel.cs:
--------------------------------------------------------------------------------
1 | using MauiShellApp.Models;
2 | using System.Diagnostics;
3 |
4 | namespace MauiShellApp.ViewModels;
5 |
6 | [QueryProperty(nameof(ItemId), nameof(ItemId))]
7 | public class ItemDetailViewModel : BaseViewModel
8 | {
9 | private string itemId;
10 | private string text;
11 | private string description;
12 | public string Id { get; set; }
13 |
14 | public string Text
15 | {
16 | get => text;
17 | set => SetProperty(ref text, value);
18 | }
19 |
20 | public string Description
21 | {
22 | get => description;
23 | set => SetProperty(ref description, value);
24 | }
25 |
26 | public string ItemId
27 | {
28 | get
29 | {
30 | return itemId;
31 | }
32 | set
33 | {
34 | itemId = value;
35 | LoadItemId(value);
36 | }
37 | }
38 |
39 | public async void LoadItemId(string itemId)
40 | {
41 | try
42 | {
43 | var item = await DataStore.GetItemAsync(itemId);
44 | Id = item.Id;
45 | Text = item.Text;
46 | Description = item.Description;
47 | }
48 | catch (Exception)
49 | {
50 | Debug.WriteLine("Failed to Load Item");
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/MauiShellApp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.0.31611.283
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiShellApp", "MauiShellApp\MauiShellApp.csproj", "{4AD51E54-62D3-4A0E-99F4-830132AD9087}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {4AD51E54-62D3-4A0E-99F4-830132AD9087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {4AD51E54-62D3-4A0E-99F4-830132AD9087}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {4AD51E54-62D3-4A0E-99F4-830132AD9087}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17 | {4AD51E54-62D3-4A0E-99F4-830132AD9087}.Release|Any CPU.ActiveCfg = Release|Any CPU
18 | {4AD51E54-62D3-4A0E-99F4-830132AD9087}.Release|Any CPU.Build.0 = Release|Any CPU
19 | {4AD51E54-62D3-4A0E-99F4-830132AD9087}.Release|Any CPU.Deploy.0 = Release|Any CPU
20 | EndGlobalSection
21 | GlobalSection(SolutionProperties) = preSolution
22 | HideSolutionNode = FALSE
23 | EndGlobalSection
24 | GlobalSection(ExtensibilityGlobals) = postSolution
25 | SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
26 | EndGlobalSection
27 | EndGlobal
28 |
--------------------------------------------------------------------------------
/MauiShellApp/ViewModels/BaseViewModel.cs:
--------------------------------------------------------------------------------
1 | using MauiShellApp.Models;
2 | using MauiShellApp.Services;
3 | using System.ComponentModel;
4 | using System.Runtime.CompilerServices;
5 |
6 | namespace MauiShellApp.ViewModels;
7 |
8 | public class BaseViewModel : INotifyPropertyChanged
9 | {
10 | public IDataStore- DataStore => DependencyService.Get>();
11 |
12 | bool isBusy = false;
13 | public bool IsBusy
14 | {
15 | get { return isBusy; }
16 | set { SetProperty(ref isBusy, value); }
17 | }
18 |
19 | string title = string.Empty;
20 | public string Title
21 | {
22 | get { return title; }
23 | set { SetProperty(ref title, value); }
24 | }
25 |
26 | protected bool SetProperty(ref T backingStore, T value,
27 | [CallerMemberName] string propertyName = "",
28 | Action onChanged = null)
29 | {
30 | if (EqualityComparer.Default.Equals(backingStore, value))
31 | return false;
32 |
33 | backingStore = value;
34 | onChanged?.Invoke();
35 | OnPropertyChanged(propertyName);
36 | return true;
37 | }
38 |
39 | #region INotifyPropertyChanged
40 | public event PropertyChangedEventHandler PropertyChanged;
41 | protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
42 | {
43 | var changed = PropertyChanged;
44 | if (changed == null)
45 | return;
46 |
47 | changed.Invoke(this, new PropertyChangedEventArgs(propertyName));
48 | }
49 | #endregion
50 | }
--------------------------------------------------------------------------------
/MauiShellApp/ViewModels/NewItemViewModel.cs:
--------------------------------------------------------------------------------
1 | using MauiShellApp.Models;
2 |
3 | namespace MauiShellApp.ViewModels;
4 |
5 | public class NewItemViewModel : BaseViewModel
6 | {
7 | private string text;
8 | private string description;
9 |
10 | public NewItemViewModel()
11 | {
12 | SaveCommand = new Command(OnSave, ValidateSave);
13 | CancelCommand = new Command(OnCancel);
14 | this.PropertyChanged +=
15 | (_, __) => SaveCommand.ChangeCanExecute();
16 | }
17 |
18 | private bool ValidateSave()
19 | {
20 | return !String.IsNullOrWhiteSpace(text)
21 | && !String.IsNullOrWhiteSpace(description);
22 | }
23 |
24 | public string Text
25 | {
26 | get => text;
27 | set => SetProperty(ref text, value);
28 | }
29 |
30 | public string Description
31 | {
32 | get => description;
33 | set => SetProperty(ref description, value);
34 | }
35 |
36 | public Command SaveCommand { get; }
37 | public Command CancelCommand { get; }
38 |
39 | private async void OnCancel()
40 | {
41 | // This will pop the current page off the navigation stack
42 | await Shell.Current.GoToAsync("..");
43 | }
44 |
45 | private async void OnSave()
46 | {
47 | Item newItem = new Item()
48 | {
49 | Id = Guid.NewGuid().ToString(),
50 | Text = Text,
51 | Description = Description
52 | };
53 |
54 | await DataStore.AddItemAsync(newItem);
55 |
56 | // This will pop the current page off the navigation stack
57 | await Shell.Current.GoToAsync("..");
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/MauiShellApp/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 | #2196F3
10 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/MauiShellApp/Resources/appiconfg.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/MauiShellApp/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
9 |
10 |
16 |
17 |
24 |
25 |
32 |
33 |
40 |
41 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/MauiShellApp/Services/MockDataStore.cs:
--------------------------------------------------------------------------------
1 | using MauiShellApp.Models;
2 |
3 | namespace MauiShellApp.Services;
4 |
5 | public class MockDataStore : IDataStore
-
6 | {
7 | readonly List
- items;
8 |
9 | public MockDataStore()
10 | {
11 | items = new List
- ()
12 | {
13 | new Item { Id = Guid.NewGuid().ToString(), Text = "First item", Description="This is an item description." },
14 | new Item { Id = Guid.NewGuid().ToString(), Text = "Second item", Description="This is an item description." },
15 | new Item { Id = Guid.NewGuid().ToString(), Text = "Third item", Description="This is an item description." },
16 | new Item { Id = Guid.NewGuid().ToString(), Text = "Fourth item", Description="This is an item description." },
17 | new Item { Id = Guid.NewGuid().ToString(), Text = "Fifth item", Description="This is an item description." },
18 | new Item { Id = Guid.NewGuid().ToString(), Text = "Sixth item", Description="This is an item description." }
19 | };
20 | }
21 |
22 | public async Task AddItemAsync(Item item)
23 | {
24 | items.Add(item);
25 |
26 | return await Task.FromResult(true);
27 | }
28 |
29 | public async Task UpdateItemAsync(Item item)
30 | {
31 | var oldItem = items.Where((Item arg) => arg.Id == item.Id).FirstOrDefault();
32 | items.Remove(oldItem);
33 | items.Add(item);
34 |
35 | return await Task.FromResult(true);
36 | }
37 |
38 | public async Task DeleteItemAsync(string id)
39 | {
40 | var oldItem = items.Where((Item arg) => arg.Id == id).FirstOrDefault();
41 | items.Remove(oldItem);
42 |
43 | return await Task.FromResult(true);
44 | }
45 |
46 | public async Task
- GetItemAsync(string id)
47 | {
48 | return await Task.FromResult(items.FirstOrDefault(s => s.Id == id));
49 | }
50 |
51 | public async Task> GetItemsAsync(bool forceRefresh = false)
52 | {
53 | return await Task.FromResult(items);
54 | }
55 | }
--------------------------------------------------------------------------------
/MauiShellApp/ViewModels/ItemsViewModel.cs:
--------------------------------------------------------------------------------
1 | using MauiShellApp.Models;
2 | using MauiShellApp.Views;
3 | using System.Collections.ObjectModel;
4 | using System.Diagnostics;
5 |
6 | namespace MauiShellApp.ViewModels;
7 |
8 | public class ItemsViewModel : BaseViewModel
9 | {
10 | private Item _selectedItem;
11 |
12 | public ObservableCollection
- Items { get; }
13 | public Command LoadItemsCommand { get; }
14 | public Command AddItemCommand { get; }
15 | public Command
- ItemTapped { get; }
16 |
17 | public ItemsViewModel()
18 | {
19 | Title = "Browse";
20 | Items = new ObservableCollection
- ();
21 | LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommand());
22 |
23 | ItemTapped = new Command
- (OnItemSelected);
24 |
25 | AddItemCommand = new Command(OnAddItem);
26 | }
27 |
28 | async Task ExecuteLoadItemsCommand()
29 | {
30 | IsBusy = true;
31 |
32 | try
33 | {
34 | Items.Clear();
35 | var items = await DataStore.GetItemsAsync(true);
36 | foreach (var item in items)
37 | {
38 | Items.Add(item);
39 | }
40 | }
41 | catch (Exception ex)
42 | {
43 | Debug.WriteLine(ex);
44 | }
45 | finally
46 | {
47 | IsBusy = false;
48 | }
49 | }
50 |
51 | public void OnAppearing()
52 | {
53 | IsBusy = true;
54 | SelectedItem = null;
55 | }
56 |
57 | public Item SelectedItem
58 | {
59 | get => _selectedItem;
60 | set
61 | {
62 | SetProperty(ref _selectedItem, value);
63 | OnItemSelected(value);
64 | }
65 | }
66 |
67 | private async void OnAddItem(object obj)
68 | {
69 | await Shell.Current.GoToAsync(nameof(NewItemPage));
70 | }
71 |
72 | async void OnItemSelected(Item item)
73 | {
74 | if (item == null)
75 | return;
76 |
77 | // This will push the ItemDetailPage onto the navigation stack
78 | await Shell.Current.GoToAsync($"{nameof(ItemDetailPage)}?{nameof(ItemDetailViewModel.ItemId)}={item.Id}");
79 | }
80 | }
--------------------------------------------------------------------------------
/MauiShellApp/Platforms/Windows/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
13 |
14 |
15 | MauiShellApp
16 | Microsoft
17 | Assets\appiconStoreLogo.png
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
33 |
39 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/MauiShellApp/Views/ItemsPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
17 |
18 |
21 |
22 |
23 |
24 |
28 |
32 |
33 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/MauiShellApp/Views/AboutPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | #96d1ff
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
44 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/MauiShellApp/MauiShellApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0-android;net6.0-ios;net6.0-maccatalyst
5 | $(TargetFrameworks);net6.0-windows10.0.19041
6 | Exe
7 | MauiShellApp
8 | true
9 | true
10 | enable
11 | true
12 |
13 |
14 | MauiShellApp
15 |
16 |
17 | com.companyname.mauishellapp
18 |
19 |
20 | 1
21 |
22 |
23 | True
24 |
25 | 14.2
26 | 14.0
27 | 21.0
28 | 10.0.17763.0
29 | 10.0.17763.0
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | WinExe
66 | win10-x64
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/MauiShellApp/AppShell.xaml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
15 |
16 |
27 |
28 |
29 |
30 |
34 |
37 |
56 |
57 |
60 |
73 |
74 |
75 |
76 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
91 |
92 |
99 |
100 |
101 |
102 |
103 |
135 |
136 |
137 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # Tye
66 | .tye/
67 |
68 | # ASP.NET Scaffolding
69 | ScaffoldingReadMe.txt
70 |
71 | # StyleCop
72 | StyleCopReport.xml
73 |
74 | # Files built by Visual Studio
75 | *_i.c
76 | *_p.c
77 | *_h.h
78 | *.ilk
79 | *.meta
80 | *.obj
81 | *.iobj
82 | *.pch
83 | *.pdb
84 | *.ipdb
85 | *.pgc
86 | *.pgd
87 | *.rsp
88 | *.sbr
89 | *.tlb
90 | *.tli
91 | *.tlh
92 | *.tmp
93 | *.tmp_proj
94 | *_wpftmp.csproj
95 | *.log
96 | *.vspscc
97 | *.vssscc
98 | .builds
99 | *.pidb
100 | *.svclog
101 | *.scc
102 |
103 | # Chutzpah Test files
104 | _Chutzpah*
105 |
106 | # Visual C++ cache files
107 | ipch/
108 | *.aps
109 | *.ncb
110 | *.opendb
111 | *.opensdf
112 | *.sdf
113 | *.cachefile
114 | *.VC.db
115 | *.VC.VC.opendb
116 |
117 | # Visual Studio profiler
118 | *.psess
119 | *.vsp
120 | *.vspx
121 | *.sap
122 |
123 | # Visual Studio Trace Files
124 | *.e2e
125 |
126 | # TFS 2012 Local Workspace
127 | $tf/
128 |
129 | # Guidance Automation Toolkit
130 | *.gpState
131 |
132 | # ReSharper is a .NET coding add-in
133 | _ReSharper*/
134 | *.[Rr]e[Ss]harper
135 | *.DotSettings.user
136 |
137 | # TeamCity is a build add-in
138 | _TeamCity*
139 |
140 | # DotCover is a Code Coverage Tool
141 | *.dotCover
142 |
143 | # AxoCover is a Code Coverage Tool
144 | .axoCover/*
145 | !.axoCover/settings.json
146 |
147 | # Coverlet is a free, cross platform Code Coverage Tool
148 | coverage*.json
149 | coverage*.xml
150 | coverage*.info
151 |
152 | # Visual Studio code coverage results
153 | *.coverage
154 | *.coveragexml
155 |
156 | # NCrunch
157 | _NCrunch_*
158 | .*crunch*.local.xml
159 | nCrunchTemp_*
160 |
161 | # MightyMoose
162 | *.mm.*
163 | AutoTest.Net/
164 |
165 | # Web workbench (sass)
166 | .sass-cache/
167 |
168 | # Installshield output folder
169 | [Ee]xpress/
170 |
171 | # DocProject is a documentation generator add-in
172 | DocProject/buildhelp/
173 | DocProject/Help/*.HxT
174 | DocProject/Help/*.HxC
175 | DocProject/Help/*.hhc
176 | DocProject/Help/*.hhk
177 | DocProject/Help/*.hhp
178 | DocProject/Help/Html2
179 | DocProject/Help/html
180 |
181 | # Click-Once directory
182 | publish/
183 |
184 | # Publish Web Output
185 | *.[Pp]ublish.xml
186 | *.azurePubxml
187 | # Note: Comment the next line if you want to checkin your web deploy settings,
188 | # but database connection strings (with potential passwords) will be unencrypted
189 | *.pubxml
190 | *.publishproj
191 |
192 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
193 | # checkin your Azure Web App publish settings, but sensitive information contained
194 | # in these scripts will be unencrypted
195 | PublishScripts/
196 |
197 | # NuGet Packages
198 | *.nupkg
199 | # NuGet Symbol Packages
200 | *.snupkg
201 | # The packages folder can be ignored because of Package Restore
202 | **/[Pp]ackages/*
203 | # except build/, which is used as an MSBuild target.
204 | !**/[Pp]ackages/build/
205 | # Uncomment if necessary however generally it will be regenerated when needed
206 | #!**/[Pp]ackages/repositories.config
207 | # NuGet v3's project.json files produces more ignorable files
208 | *.nuget.props
209 | *.nuget.targets
210 |
211 | # Microsoft Azure Build Output
212 | csx/
213 | *.build.csdef
214 |
215 | # Microsoft Azure Emulator
216 | ecf/
217 | rcf/
218 |
219 | # Windows Store app package directories and files
220 | AppPackages/
221 | BundleArtifacts/
222 | Package.StoreAssociation.xml
223 | _pkginfo.txt
224 | *.appx
225 | *.appxbundle
226 | *.appxupload
227 |
228 | # Visual Studio cache files
229 | # files ending in .cache can be ignored
230 | *.[Cc]ache
231 | # but keep track of directories ending in .cache
232 | !?*.[Cc]ache/
233 |
234 | # Others
235 | ClientBin/
236 | ~$*
237 | *~
238 | *.dbmdl
239 | *.dbproj.schemaview
240 | *.jfm
241 | *.pfx
242 | *.publishsettings
243 | orleans.codegen.cs
244 |
245 | # Including strong name files can present a security risk
246 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
247 | #*.snk
248 |
249 | # Since there are multiple workflows, uncomment next line to ignore bower_components
250 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
251 | #bower_components/
252 |
253 | # RIA/Silverlight projects
254 | Generated_Code/
255 |
256 | # Backup & report files from converting an old project file
257 | # to a newer Visual Studio version. Backup files are not needed,
258 | # because we have git ;-)
259 | _UpgradeReport_Files/
260 | Backup*/
261 | UpgradeLog*.XML
262 | UpgradeLog*.htm
263 | ServiceFabricBackup/
264 | *.rptproj.bak
265 |
266 | # SQL Server files
267 | *.mdf
268 | *.ldf
269 | *.ndf
270 |
271 | # Business Intelligence projects
272 | *.rdl.data
273 | *.bim.layout
274 | *.bim_*.settings
275 | *.rptproj.rsuser
276 | *- [Bb]ackup.rdl
277 | *- [Bb]ackup ([0-9]).rdl
278 | *- [Bb]ackup ([0-9][0-9]).rdl
279 |
280 | # Microsoft Fakes
281 | FakesAssemblies/
282 |
283 | # GhostDoc plugin setting file
284 | *.GhostDoc.xml
285 |
286 | # Node.js Tools for Visual Studio
287 | .ntvs_analysis.dat
288 | node_modules/
289 |
290 | # Visual Studio 6 build log
291 | *.plg
292 |
293 | # Visual Studio 6 workspace options file
294 | *.opt
295 |
296 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
297 | *.vbw
298 |
299 | # Visual Studio LightSwitch build output
300 | **/*.HTMLClient/GeneratedArtifacts
301 | **/*.DesktopClient/GeneratedArtifacts
302 | **/*.DesktopClient/ModelManifest.xml
303 | **/*.Server/GeneratedArtifacts
304 | **/*.Server/ModelManifest.xml
305 | _Pvt_Extensions
306 |
307 | # Paket dependency manager
308 | .paket/paket.exe
309 | paket-files/
310 |
311 | # FAKE - F# Make
312 | .fake/
313 |
314 | # CodeRush personal settings
315 | .cr/personal
316 |
317 | # Python Tools for Visual Studio (PTVS)
318 | __pycache__/
319 | *.pyc
320 |
321 | # Cake - Uncomment if you are using it
322 | # tools/**
323 | # !tools/packages.config
324 |
325 | # Tabs Studio
326 | *.tss
327 |
328 | # Telerik's JustMock configuration file
329 | *.jmconfig
330 |
331 | # BizTalk build output
332 | *.btp.cs
333 | *.btm.cs
334 | *.odx.cs
335 | *.xsd.cs
336 |
337 | # OpenCover UI analysis results
338 | OpenCover/
339 |
340 | # Azure Stream Analytics local run output
341 | ASALocalRun/
342 |
343 | # MSBuild Binary and Structured Log
344 | *.binlog
345 |
346 | # NVidia Nsight GPU debugger configuration file
347 | *.nvuser
348 |
349 | # MFractors (Xamarin productivity tool) working folder
350 | .mfractor/
351 |
352 | # Local History for Visual Studio
353 | .localhistory/
354 |
355 | # BeatPulse healthcheck temp database
356 | healthchecksdb
357 |
358 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
359 | MigrationBackup/
360 |
361 | # Ionide (cross platform F# VS Code tools) working folder
362 | .ionide/
363 |
364 | # Fody - auto-generated XML schema
365 | FodyWeavers.xsd
366 |
367 | ##
368 | ## Visual studio for Mac
369 | ##
370 |
371 |
372 | # globs
373 | Makefile.in
374 | *.userprefs
375 | *.usertasks
376 | config.make
377 | config.status
378 | aclocal.m4
379 | install-sh
380 | autom4te.cache/
381 | *.tar.gz
382 | tarballs/
383 | test-results/
384 |
385 | # Mac bundle stuff
386 | *.dmg
387 | *.app
388 |
389 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
390 | # General
391 | .DS_Store
392 | .AppleDouble
393 | .LSOverride
394 |
395 | # Icon must end with two \r
396 | Icon
397 |
398 |
399 | # Thumbnails
400 | ._*
401 |
402 | # Files that might appear in the root of a volume
403 | .DocumentRevisions-V100
404 | .fseventsd
405 | .Spotlight-V100
406 | .TemporaryItems
407 | .Trashes
408 | .VolumeIcon.icns
409 | .com.apple.timemachine.donotpresent
410 |
411 | # Directories potentially created on remote AFP share
412 | .AppleDB
413 | .AppleDesktop
414 | Network Trash Folder
415 | Temporary Items
416 | .apdisk
417 |
418 | # content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
419 | # Windows thumbnail cache files
420 | Thumbs.db
421 | ehthumbs.db
422 | ehthumbs_vista.db
423 |
424 | # Dump file
425 | *.stackdump
426 |
427 | # Folder config file
428 | [Dd]esktop.ini
429 |
430 | # Recycle Bin used on file shares
431 | $RECYCLE.BIN/
432 |
433 | # Windows Installer files
434 | *.cab
435 | *.msi
436 | *.msix
437 | *.msm
438 | *.msp
439 |
440 | # Windows shortcuts
441 | *.lnk
442 |
443 | # JetBrains Rider
444 | .idea/
445 | *.sln.iml
446 |
447 | ##
448 | ## Visual Studio Code
449 | ##
450 | .vscode/*
451 | !.vscode/settings.json
452 | !.vscode/tasks.json
453 | !.vscode/launch.json
454 | !.vscode/extensions.json
455 |
--------------------------------------------------------------------------------
/MauiShellApp/Resources/Images/dotnet_bot.svg:
--------------------------------------------------------------------------------
1 |
94 |
--------------------------------------------------------------------------------