Is there a way I can have an object take up multiple grids in Windows UA?

a 夏天 提交于 2019-12-20 06:08:54

问题


I'm trying to make my first app, and I'm having a little trouble with the grids. I'm trying to make the left side of the screen a map, and the right side 2 boxes/grids. I'm not sure if there is a way to have an object within multiple grids or how to just setup a layout like that (basically a + with the left line gone)

So far, this is the code I gotten for the layout.

<Grid.RowDefinitions>
        <RowDefinition Height= "*"/>
        <RowDefinition Height= "*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <Grid Grid.Row="1">
        <!-- map -->
    </Grid>

回答1:


You can't make an element "take up" multiple grids but you can make it span multiple cells by setting Grid.RowSpan or Grid.ColumnSpan as appropriate.

e.g.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height= "*"/>
        <RowDefinition Height= "*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <!-- Map will take up left hand side -->    
    <Map Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" />

    <!-- top right -->
    <Button Content="+" Grid.Column="1" Grid.Row="0" /> 

    <!-- bottom right -->
    <List Grid.Column="1" Grid.Row="1" /> 

</Grid>


来源:https://stackoverflow.com/questions/33456341/is-there-a-way-i-can-have-an-object-take-up-multiple-grids-in-windows-ua

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!