Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Binding Listview to BindingContext and static viewmodel

$
0
0

I have a scenario where I want to bind a page to its own ViewModel but also have a control in the view that binds to a static class on the previous view.

I have the first page that is in the namespace View.MainDetailsPage and within that I have declared:
public static ViewModel.MainDetailsVM _vm;

The user navigates to a modal that shows them a list of pictures they have taken along with the ability to add more. The BindingContext of this modal is a PicturesVM that contains all the actions to be able to take a photo and what to do when saving it. On this page however I would like the ListView of pictures to bind to the ViewModel.MainDetails._vm.Photos observable collection.

I have added the namespace:
xmlns:local="clr-namespace:MyApp.View;assembley=MyApp

Then in the XAML I have
<ListView ItemsSource="{Binding _vm.Photos Source={x:Static local:MainDetailsPage}}" >

But it keeps throwing an error saying it can't find the resource. I've tried a few other permutations with no joy. Please could somebody advise where I am going wrong?

Thanks!
Richard


Viewing all articles
Browse latest Browse all 91519

Trending Articles