I'm trying to bind the Window Activated and Loaded events in a WinUI 3 desktop application to an ICommand property in my ViewModel, but running into issues.
public MainViewModel ViewModel { get; } = (App.Current as App).Container.GetService<MainViewModel>();
MainViewModel.cs
public class MainViewModel
{
public MainViewModel()
{
this.ActivatedCommand = new AsyncRelayCommand(
this.Activated);
}
public IAsyncRelayCommand ActivatedCommand { get; }
public async Task Activated()
{
await Task.Run(() =>
{
// not called
});
}
}
Hi.
I'm trying to bind the Window
Activated
andLoaded
events in a WinUI 3 desktop application to anICommand
property in myViewModel
, but running into issues.I've attached a sample app here: BindingLoadedEvent.zip
Visual Studio 2019 16.7.1 .NET v5.0.100-preview.7 WinUI 3.0.0-preview2.200713.0 Microsoft.Xaml.Behaviors.WinUI.Managed 2.0.3-rc3 Microsoft.Toolkit.Mvvm 7.0.0-preview2
With the sample code, I'm currently getting
XamlParseException: 'XAML parsing failed.'
.MainWindow.xaml
MainWindow.xaml.cs
MainViewModel.cs
Any ideas?
Thank you.