If you want to use ObservableCollection modelbs bindable property in ContentView, then use this custom control in ContentPage, I do one sample that you can take a look:
ContentView:
<ContentView
x:Class="demo3.contentview.View2"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="customlistview"
mc:Ignorable="d">
<ContentView.Content>
<StackLayout>
<ListView x:Name="listview1" ItemsSource="{Binding Items, Source={x:Reference customlistview}}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="{Binding name}" />
<Label Text="{Binding age}" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentView.Content>
public partial class View2 : ContentView
{
public static BindableProperty ItemsProperty = BindableProperty.Create("ItemsSource", typeof(ObservableCollection<object>), typeof(View2),null,BindingMode.TwoWay,propertyChanged: (bindable, oldValue, newValue) => OnItemsSourceChanged(bindable, oldValue, newValue));
private static void OnItemsSourceChanged(BindableObject bindable, object oldValue, object newValue)
{
var control =(View2)bindable;
control.listview1.ItemsSource =(ObservableCollection<object>) newValue;
}
/// <summary>
/// Accessors
/// </summary>
public ObservableCollection<object> Items
{
get { return (ObservableCollection<object>)GetValue(ItemsProperty); }
set
{
SetValue(ItemsProperty, value);
}
}
public View2()
{
InitializeComponent();
}
}
ContentPage:
<ContentPage.Content>
<StackLayout>
<local:View2 Items="{Binding modelas}" />
</StackLayout>
</ContentPage.Content>
public partial class Page26 : ContentPage
{
public ObservableCollection<object> modelas {get;set;}
public ObservableCollection<object> modelbs { get; set; }
public Page26()
{
InitializeComponent();
modelas = new ObservableCollection<object>()
{
new modela(){name="cherry",age=12},
new modela(){name="barry",age=20}
};
modelbs = new ObservableCollection<object>()
{
new modelb(){firstname="aaa",age=12},
new modelb(){firstname="bbb",age=27}
};
this.BindingContext = this;
}
}
public class modela
{
public string name { get; set; }
public int age { get; set; }
}
public class modelb
{
public string firstname { get; set; }
public int age { get; set; }
}