动态添加XAML中的行数和列数 [英] Add dynamically the number of rows and columns in XAML
本文介绍了动态添加XAML中的行数和列数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过绑定添加列数和行数。我一直在寻找它,但我只找到如何绑定内容或如何在后面的代码中以编程方式执行此任务。
我想在ColumnsDefinitions和RowDefinitions但我开始认为没有可能的方法来做到这一点。
我正在尝试做下一个事情,但我只得到XAML pasing错误:
I would like to add the number of columns and rows through binding . I have been looking for it but I only find how to bind the content or how to do this task programatically in the code behind.
I want to do it in the ColumnsDefinitions and RowDefinitions but I am starting to think that there is no possible way to do this.
I am trying to do things like next but I only get XAML pasing errors:
<Grid ShowGridLines="True" x:Name="rootGrid" >
<Style>
<Setter Property="Grid.ColumnsDefinition" Value="{Binding Path=GridRow}" />
<Setter Property="Grid.RowsDefinition" Value="{Binding Path=GridColumn}" />
</Style>
可能吗?最好的方法是什么?
is it possible? What would be the best way to do this?
推荐答案
http://msdn.microsoft.com/en-us/library/system.windows.controls.grid.columndefinitions(v = vs.110) .aspx [ ^ ]
它不是依赖属性,因此您无法绑定它。您必须在代码中执行此操作。请参阅链接以获取示例。
http://msdn.microsoft.com/en-us/library/system.windows.controls.grid.columndefinitions(v=vs.110).aspx[^]
It's not a dependency property, therefore you cannot bind to it. You will have to do it in code. See link for an example.
这篇关于动态添加XAML中的行数和列数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文