I'm using the Partial Views feature of Prism 7.1 in Xamarin in which the ContentView can have its own ViewModel. The binding to the viewmodel is working fine. However, I would also like to set a BindableProperty. For example, I would like to set a Title property on the ContentView. If the ContentView does not have its own ViewModel the Binding works fine. If it does have its own ViewModel the binding never occurs.
MainPage.xaml
<controls:CustomContentView Title="My Custom View Title"
mvvm:ViewModelLocator.AutowirePartialView="{x:Reference self}"/>
CustomContentView.cs:
public static readonly BindableProperty TitleProperty =
BindableProperty.Create(
nameof(Title),
typeof(string),
typeof(CustomContentView));
public string Title
{
get => (string)GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}
CustomContentView.xaml:
<ContentView.Content>
<StackLayout>
<Label Text="{Title}" />
</StackLayout>
</ContentView.Content>
If I set a breakpoint on the Title's set method, it never gets hit and the Title in the Label control is never bound.