after upgrade on mvvmcross 6.2.1 getting error Mvx does not contain definition of Traces , Warning , Error, etc
A lot have changed since Mvx 4. You should read the documentation, blogs and migration guides (from 4 to 5, from 5 to 6).
About traces, warning, error, now Mvx has a new way you can do Diagnostic & Logging. You have to inject/resolve IMvxLog
and there you will have all the methods to do trace, warning, error, etc.
public class MyViewModel : MvxViewModel
{
private readonly IMvxLog _log;
public MyViewModel(IMvxLog log)
{
_log = log;
}
private void SomeMethod()
{
_log.Trace("Some message");
}
}
In order to close a viewmodel you need to use the new Navigation system:
public class MyViewModel : MvxViewModel
{
private readonly IMvxNavigationService _navigationService;
public MyViewModel(IMvxNavigationService navigation)
{
_navigationService = navigationService;
}
public override void Prepare()
{
// first callback. Initialize parameter-agnostic stuff here
}
public override async Task Initialize()
{
await base.Initialize();
// do the heavy work here
}
public async Task SomeMethod()
{
var result = await _navigationService.Navigate<NextViewModel, MyObject, MyReturnObject>(new MyObject());
//Do something with the result MyReturnObject that you get back
}
}
public class NextViewModel : MvxViewModel<MyObject, MyReturnObject>
{
private readonly IMvxNavigationService _navigationService;
private MyObject _myObject;
public MyViewModel(IMvxNavigationService navigation)
{
_navigationService = navigationService;
}
public override void Prepare()
{
// first callback. Initialize parameter-agnostic stuff here
}
public override void Prepare(MyObject parameter)
{
// receive and store the parameter here
_myObject = parameter;
}
public override async Task Initialize()
{
//Do heavy work and data loading here
}
public async Task SomeMethodToClose()
{
await _navigationService.Close(this, new MyReturnObject());
}
}
If you want to return nothing just do _navigationService.Close(this)
(of course you have to remove the generic type parameter of MyReturnObject
in order to do so) and that's it.
HIH