question

EJ-5254 avatar image
0 Votes"
EJ-5254 asked EJ-5254 answered

Passing parameters to partial view with Prism

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.


dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

EJ-5254 avatar image
0 Votes"
EJ-5254 answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.