Files
ReadWriteFile_MAUI/ViewModel/MainViewModel.cs
T
2025-03-24 12:56:43 +01:00

36 lines
1.1 KiB
C#

using System.ComponentModel;
using System.Windows.Input;
using FileReadAndWrite.Model;
using FileReadAndWrite.Service;
using FileReadAndWrite.View;
namespace FileReadAndWrite.ViewModel;
public class MainViewModel : INotifyPropertyChanged {
private readonly FileService _fileService;
private readonly INavigation _navigation;
public ICommand EnterRawFileCmd { get; }
public ICommand EnterAppDataFileCmd { get; }
public MainViewModel(INavigation navigation, FileService fileService) {
_fileService = fileService;
_navigation = navigation;
EnterRawFileCmd = new Command(async() => await EnterRawFile());
EnterAppDataFileCmd = new Command(async() => await EnterAppDataFile());
}
private async Task EnterRawFile(){
await _navigation.PushAsync(new RawFilePage(_fileService));
}
private async Task EnterAppDataFile(){
await _navigation.PushAsync(new AppDataFilePage());
}
public event PropertyChangedEventHandler? PropertyChanged;
public void OnPropertyChanged(string propertyName) {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}