How to bind a ContentView content at run time to dynamically assign views.

Say I've built a component as follows:

<ContentView x:Class="MyView">
    <ContentView.Content>
        <Grid >

and a few others similar....
I'd like to define a page with some dynamic content in a stack layout

<ContentPage>
    <ContentPage.Content>
    <StackLayout>            
            <ContentView Content= "{Binding TestNavVM.CurrentView}"/>

and then in VM code....

public View CurrentView
{
    get{return view;}
    set{view = value;OnPropertyChanged();}
}
...
and 
CurrentView = new MyView();

Of course, it doesn't work, but as this question here suggests it's possible.

So - what am I doing wrong?

Posts

  • sonny_ppgsonny_ppg USMember, University ✭✭

    Did you set the binding? I don't see where you set the binding.

Sign In or Register to comment.