I have made a repo on github with the simple project.
My Caliburn Experiment
Basicly im just trying to set the active item, and then deactivate it and then set it again.
switching between page 1 and page 2 or just opening and closing page 1 or 2 a few times will have the same result.
Screenshot is from DotMemory.
This is the code i currently have.
public class ShellViewModel:Conductor<IScreen>
{
private readonly IEventAggregator _eventAggregator;
public ShellViewModel(IEventAggregator eventAggregator)
{
_eventAggregator = eventAggregator;
if(eventAggregator != null)
{
_eventAggregator.SubscribeOnUIThread(this);
}
}
protected override async void OnViewLoaded(object view)
{
base.OnViewLoaded(view);
}
public async Task Page1()
{
await OpenModal(new Page1ViewModel());
}
public async Task Page2()
{
await OpenModal(new Page2ViewModel());
}
public async Task OpenModal(IScreen screen)
{
await ActivateItemAsync(screen);
ModalIsVisible = true;
}
private bool _modalIsVisible;
public bool ModalIsVisible { get { return _modalIsVisible; } set { _modalIsVisible = value; NotifyOfPropertyChange(() => ModalIsVisible); } }
public async Task CloseModal()
{
await DeactivateItemAsync(ActiveItem,true, new CancellationToken());
ModalIsVisible = false;
}
public async Task HandleAsync(OpenModalEvent message, CancellationToken cancellationToken)
{
await OpenModal(message.Modal);
}
}
I have mostly just tried to Deactivate and TryCloseAsync();
I could possibly have the screen stored somewhere and have it reactivated again and not new it up again. but just getting a fresh viewmodel/view is what i would like i think.
I am probably just missunderstanding the whole thing. but if someone could guide me in the right path it would be greatly appriciated.