本文介绍了有没有办法让一个对象在 Windows UA 中占据多个网格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作我的第一个应用程序,但在网格方面遇到了一些问题.我正在尝试将屏幕左侧制作成地图,右侧制作 2 个框/网格.我不确定是否有办法在多个网格中放置一个对象,或者如何设置这样的布局(基本上是一个 +,左边的线不见了)

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>

推荐答案

你不能让一个元素占据"多个网格,但你可以通过设置 Grid.RowSpan 让它跨越多个单元格或 Grid.ColumnSpan(视情况而定).

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.

例如

<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>

这篇关于有没有办法让一个对象在 Windows UA 中占据多个网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 22:25