Caliburn-Micro / Caliburn.Micro

A small, yet powerful framework, designed for building applications across all XAML platforms. Its strong support for MV* patterns will enable you to build your solution quickly, without the need to sacrifice code quality or testability.
http://caliburnmicro.com/
MIT License
2.8k stars 778 forks source link

ContentControl ActivateItemAsync .NET Core #718

Closed AcidRaZor closed 4 years ago

AcidRaZor commented 4 years ago

I'm having some difficulty with Caliburn not picking up the ContentControl. I've tried using x:Name="ActivateItem" and x:Name="ActivateItemAsync" but neither works when I call await ActivateItemAsync and use the IoC to get the ViewModel

Everything is setup correctly as far as I'm aware. I've been working on a new .NET Core project, the only part I need to finish now is the ContentControl navigation between UserControls

mbreckon commented 4 years ago

I think that should be ActiveItem.

AcidRaZor commented 4 years ago

Yup, tried that. I even have my navigation happen on Shell using event aggregators and everything gets called, except when ActivateItemAsync runs, it doesnt change the ContentControl. (There is no ActivateItem for the .net core 3 implementation if that is what you were referring to)

/edit One thing I havent tried is binding the control explicitly instead of relying on Caliburn to resolve it for me. Will try that

CoreyVincent commented 4 years ago

ActiveItem works for me. I'm using Caliburn.Micro 4.0.140-rc.

View: <ContentControl x:Name="ActiveItem" /> ShellViewModel:

public class ShellViewModel : Conductor
{
  public ShellViewModel()
  {
    ActivateItemAsync(new MainViewModel())
  }
}

MainViewModel:

public class MainViewModel : Screen
{
  public MainViewModel()
  {

  }
}
AcidRaZor commented 4 years ago

@CoreyVincent My mistake was using ActivateItem as the name for the content control, not ActiveItem. Thanks so much for your input with code example. Otherwise I would not have realized my mistake.