I'm trying to develop with this library in MVVM architecture using Prism or CommunityToolkit.Mvvm, but in MainWindow.xaml.cs I get an error that DataContext is not an attachable property.
I'm not very familiar with MVVM, but if I want to make the following code into ViewModel, how should I set it on the View side?
namespace WinUIExSample.ViewModels
{
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.UI.Xaml;
public class MainWindowViewModel : ObservableObject
{
public IRelayCommand ExitCommand { get; }
public MainWindowViewModel()
{
ExitCommand = new RelayCommand(ExecuteExitCommand);
}
private void ExecuteExitCommand()
{
Application.Current.Exit();
}
}
}
I'm trying to develop with this library in MVVM architecture using Prism or CommunityToolkit.Mvvm, but in MainWindow.xaml.cs I get an error that DataContext is not an attachable property.
I'm not very familiar with MVVM, but if I want to make the following code into ViewModel, how should I set it on the View side?