Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

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

$
0
0

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?


Viewing all articles
Browse latest Browse all 204402

Trending Articles