Passing parameters to partial view with Prism

EJ 366 Reputation points
2021-04-13T07:29:47.667+00:00

Hi,

I've started using Prism partial views with their own respective view models for reusability. My question is how can I pass parameters to ctor when partial view is created? EventsAggregator is not suitable as I want to filter events in the partial view depending on parent object.

This is how I declare partial view in XAML, the rest is done automagically by Prism:

    <dxn:TabViewItem.Content>
        <local:CommentsListView prism:ViewModelLocator.AutowirePartialView="{x:Reference self}"/>
    </dxn:TabViewItem.Content>

For example, I've view model called JobViewModel, which contains several partial views like CommentsListViewModel, StockListViewModel etc. When CommentsListViewModel or StockListViewModel is created I need it to know which Job number they belong to so I can only filter events from this Job.

Thanks in advance.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,296 questions
0 comments No comments
{count} votes

Accepted answer
  1. EJ 366 Reputation points
    2021-04-14T01:44:20.297+00:00

    Answering to my own question, might help someone in the future - partial views are initialized with same parameters as parent view model.

    0 comments No comments

0 additional answers

Sort by: Most helpful