I'm converting a xaml app to .net maui.
I'm not able to find where I'm missing code that is keeping the button from firing the exit code in my viewmodel.
i've compared the code for the exit page to my collection page ( In which the button works) but I not able to see what I've left out of the exit code to have the app trigger the exit code.
both pages inherited from BaseViewModel
xaml page
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MapleSugarMaui.Views.ExitAppPage"
xmlns:local="clr-namespace:MapleSugarMaui"
xmlns:vm="clr-namespace:MapleSugarMaui.ViewModels"
x:DataType="vm:ExitAppViewModel"
xmlns:models="clr-namespace:MapleSugarMaui.Models"
NavigationPage.HasNavigationBar="False">
<ContentPage.BindingContext>
<vm:ExitAppViewModel/>
</ContentPage.BindingContext>
<ContentPage.Content>
<StackLayout>
<StackLayout Orientation="Horizontal" HeightRequest="45">
<Entry Placeholder="StatusMsg" Text="{Binding StatusMsg}" FontSize="15" Margin="150,0,0,0"
HorizontalTextAlignment="Center" TextColor="Red" HorizontalOptions="Center" WidthRequest="500"
IsVisible="True"/>
</StackLayout>
<StackLayout Orientation="Vertical" HeightRequest="100" >
<Label Text="Close App?" HorizontalOptions="CenterAndExpand" FontSize="30" TextColor="Red" FontAttributes="Bold" Margin="0,10,0,0"/>
<StackLayout Orientation="Horizontal" HeightRequest="45" Margin="50">
<Button Text="Close"
HorizontalOptions="CenterAndExpand"
WidthRequest="150"
HeightRequest="50"
VerticalOptions="CenterAndExpand"
BackgroundColor="White"
TextColor="Black"
BorderWidth="2"
BorderColor="Black"
CornerRadius="15"
Command="{Binding ExitAppActionCommand}"/>
</StackLayout >
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
xaml.cs page
using MapleSugarMaui.ViewModels;
namespace MapleSugarMaui.Views;
public partial class ExitAppPage : ContentPage
{
public ExitAppPage()
{
InitializeComponent();
BindingContext = new ExitAppViewModel();
}
}
ViewModel Page
using CommunityToolkit.Mvvm.Input;
namespace MapleSugarMaui.ViewModels
{
public partial class ExitAppViewModel : BaseViewModel
{
public ExitAppViewModel()
{
StatusMsg = "Close ??";
}
[RelayCommand]
private void ExitAppAction()
{
StatusMsg = "Closing App";
System.Environment.Exit(0);
}
}
}
TIA
Tim