The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

ying-hui.the@windev.co.uk (47) [Avatar] Offline
#1
await navigation.Navigate<CounterViewModel>(new Counter()); // this line.


the intellisence red flags the item: navigation

I tried changing it to: navigationService

But then "new Counter" is red flaged.

Q: What s my deliberate mistake, please?
Jim Bennett (89) [Avatar] Offline
#2
You are correct - it should be navigationService, not navigation. Good spot, I'll update the listing.

Not sure why you get an error around new Counter(). Have you added the using directive:

using Countr.Core.Models;
ying-hui.the@windev.co.uk (47) [Avatar] Offline
#3
problem seems to be that in listing 8.33 CountersViewModel has two parameters for the constructor.

viewModel = new CountersViewModel(mockCountersService.Object, messenger.Object);
Jim Bennett (89) [Avatar] Offline
#4
Can you hover over the red intellisense squiggle and see what the error is?

Does your counterviewmodel derive from MvxViewModel<Counter>?

I really need a lot more information to help than just a line of code that has errors. The error itself would be useful, either from hovering over the squiggle or building and seeing the errors window.
ying-hui.the@windev.co.uk (47) [Avatar] Offline
#5
so

Listing 8.37

async Task ShowAddNewCounter()
{
await navigationService.Navigate<CounterViewModel>(new Counter()); // Listing 8.37
}

The error is:
Severity Code Description Project File Line Suppression State
Error CS1503 Argument 1: cannot convert from 'MxMediControl01.Core.Models.Counter' to 'MvvmCross.Core.ViewModels.IMvxBundle'

Cant figure out what i have done wrong.
ying-hui.the@windev.co.uk (47) [Avatar] Offline
#6
yes it does derive..

public class CounterViewModel : MvxViewModel<Counter>
Jim Bennett (89) [Avatar] Offline
#7
Good spot - it's another error in the listing (but the sample code has it correct).

You need to use:

await navigationService.Navigate<CounterViewModel, Counter>(new Counter());


Note the second generic parameter to the Navigate call, you'll need to add this.

Will get the MEAP updated. Thanks!