> For the complete documentation index, see [llms.txt](https://yanxiaodi.gitbook.io/xamarin-mvvmcross-handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yanxiaodi.gitbook.io/xamarin-mvvmcross-handbook/using-mvvmcross-to-create-your-first-xamarin-app/navigation/retrieving-the-param-from-the-previous-viewmodel.md).

# Retrieving the param from the previous ViewModel

In the `PostDetailViewModel`, we need to get the param from the `IMvxNavigationService`. Change the basic class of the `PostDetailViewModel` like this:

```csharp
public class PostDetailViewModel : MvxViewModel
```

Now it has a generic type constraint to receive the param. To do this, we need to update the Prepare override method, which is the right place to receive the param that is passed by the previous ViewModel. Add a private variable to store the post id:

```csharp
private int _postId;
```

Create a new object to store the comments:

```csharp
#region CommentList;
private MvxObservableCollection<Comment> _commentList;
public MvxObservableCollection<Comment> CommentList
{
    get => _commentList;
    set => SetProperty(ref _commentList, value);
}
#endregion
```

And update the `Prepare` method to initialize the variables like this:

```csharp
public override void Prepare(Post post)
{
    // This is the first method to be called after construction
    CommentList = new MvxObservableCollection<Comment>();
    _postId = post.Id;
}
```

After that, we can use the `_postId` variable in the Initialize method to load the data from the APIs, as shown below:

```csharp
public override async Task Initialize()
{
    // Async initialization, YEY!
    await base.Initialize();
    await GetPost(_postId);
    await GetComments(_postId);
}
```

Here is the result of the Android project:

![](https://847068821-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LPK_0Nj6gmm5SSTHfcs%2F-LPQ5ikJlfjffuzWfzp1%2F-LPQ73LzeFeubUwp0PfB%2Fimage.png?alt=media\&token=0018e412-ddc7-4ecf-8d51-f6285e6bf7d6)

For the UWP project:

![](https://847068821-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LPK_0Nj6gmm5SSTHfcs%2F-LPQ5ikJlfjffuzWfzp1%2F-LPQ77VkEVbFL3iGo421%2Fimage.png?alt=media\&token=556b2e61-deb3-44eb-a803-276d96fba925)

Let us get deep into the `IMvxNavigationService` in the next section.
