简体   繁体   中英

Set Parent view (xaml, maui)

I have a main layout with a content view that I want to populate with a bunch a different views.

I thought I would set the parent view from the child, but I haven't figured out how. There may be a better way to accomplish this though.

Layout file:

<ContentPage ...>

<Grid RowDefinitions="*,Auto,*">
...
<ContentView x:Name="ViewToPopulate"
    Grid.Row="1"/>
...
</ContentPage>

Sublayout file:

<ContentView ...
    Parent="StaticResource ViewToPopulate">

<GridView >
...
</GridView>
</ContentView>

Like @Jason said, you don't set the parent from the child. I found the best way to do this is follow this suggestion that @Jason also made in the comment of: Header and Footer in .NET MAUI

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM