开发者

WPF dock control to cell in grid

开发者 https://www.devze.com 2023-02-06 13:50 出处:网络
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?

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

精彩评论

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