开发者

WPF dock control to cell in grid

If I have a 2 by 2 Grid how d开发者_开发问答o I get a button to fill the entire cell? Do I have to use a trigger? How would I get the column's width in that case?

Thanks Ian


The Button by default will consume the entire cell.

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="100"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Button></Button>
    </Grid>

You can get the columns width by accessing the ColumnDefinitions collection.

Grid g = new Grid();
g.ColumnDefinitions[0].Width;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜