添加网格在代码隐藏 [英] Adding Grids In codeBehind

查看:116
本文介绍了添加网格在代码隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要分割电网为行,我们给它排定义和的UIElement 需要被放置在一个特定的行在电网,我们做的是这样的:

To divide a Grid into rows we give it row definitions and the UIElement that needs to be placed in a particular row in that grid we do it like this:

Button Name="Button1" Grid.Row="1"

现在假设我想要做的代码这件事情的背后动态那么如何才能做到这一点。

Now suppose I want to do this thing in code behind dynamically then how can we do it.

感谢您。

推荐答案

您可以做的一切,从后面的代码,你可以从关于网格XAML:

You can do everything from code behind that you can from XAML regarding grids:

Grid.SetRow(button, 1);
Grid.SetColumn(button, 1);
Grid.SetRowSpan(button, 2);
Grid.SetColumnSpan(button, 2);

myGrid.ColumnDefinitions.Add(new ColumnDefinition());
myGrid.RowDefinitions.Add(new RowDefinition());



等等...

etc...

这篇关于添加网格在代码隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆