Virtualman
Virtualman

Reputation: 11

ContentView ViewModelLocator.AutowireViewModel

I am trying to auto wire my view model to my content view in Xamarin forms using this syntax:

<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
             prism:ViewModelLocator.AutowireViewModel="True"
             x:Class="APP.Views.PostEntryView"
             x:Name="postEntryView">

the name of my view model is PostEntryViewViewModel but it does not doing anything

Is there any way to auto wire a content view to a view model, how I have to register it in the container??

Upvotes: 1

Views: 1561

Answers (1)

Dan Siegel
Dan Siegel

Reputation: 5799

Rename your ViewModel to PostEntryViewModel. The default naming would be as follows:

View              ViewModel
SomeView          SomeViewModel
SomePage          SomePageViewModel
Something         SomethingViewModel

Alternatively you may follow something like the function the Container Extensions use to register a specific View and ViewModel

Upvotes: 1

Related Questions