Carlos
Carlos

Reputation: 386

Include a dynamic generated Stacklayout to a xaml

So, I'm building an app similar that recievies from an external source a user generated form. I currenctly have a C# class that recieves a form object and creates a stacklayout with all the correct components (entrys, switches...).

What I want to do is to be able to "include" this layout in a generic template that has a button and a header.

I tried the Content = _myCustomForm() but this doesnt work, as it removes the original contents from the page.

Upvotes: 0

Views: 49

Answers (1)

Diego Rafael Souza
Diego Rafael Souza

Reputation: 5313

Is that something you're looking for?

XAML:

<StackLayout>
    <Label Text="HEADER"
           HorizontalOptions="FillAndExpand"
           HorizontalTextAlignment="Center"/>
        <ScrollView HorizontalOptions="FillAndExpand"
                    VerticalOptions="FillAndExpand">
            <ContentView x:Name="myCustomContent"
                         HorizontalOptions="FillAndExpand"
                         VerticalOptions="FillAndExpand"/>
        </ScrollView>
    <Button Text="Do Something"
            HorizontalOptions="FillAndExpand"/>
</StackLayout>

CS:

// ...
myCustomContent.Content = _myCustomForm();
// ...

Upvotes: 1

Related Questions