银光与JS:获取通过 Javascript 来自 XAML 的名称或 uid
我正在尝试获取
这样,如果用户输入数字“20”,则 20
问题是
有什么想法吗?
谢谢
I am trying to obtain the <RowDefinitions> element from my Xaml, through Javascript, so I can add new <RowDefinition> elements to it at runtime.
This way, if a user inputs the number '20', then 20 <RowDefinition> elements will be added to <RowDefinitions>.
The problem is that <RowDefinitions> does not have a possibility for x:Name. It only has x:uid. So would it be possible to fetch the uid from within Javascript? I need the <RowDefinitions> Element one way or another (but only through JS). I need to add <RowDefinition> elements to it.
Any ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设 Javascript API
不存在
这样的元素,您将引用Grid
RowDefinitions 属性code> 元素,在 Xaml 中表示为
。因此,您可以使用FindName 获取Grid
,然后使用GetValue
获取行定义的集合。让我们假设您有一个简单的 Xaml 来开始: -所以在您的 Javascript 中您可以有这样的代码: -
这将从
Grid
中获取RowDefinitions
集合(在本例是发送者,但您可以轻松地使用 FindName 来获取命名网格,然后循环添加 20 个 RowDefintion 实例。Assuming Javascript API
There is no such element as
<RowDefinitions>
you will be refering to theRowDefinitions
property of aGrid
element which is represented as<Grid.RowDefinitions>
in Xaml. Hence you use FindName to aquire theGrid
then useGetValue
to get the collection of row definitions. Lets assume you have this simple Xaml to start with:-So in your Javascript you have can have this code:-
This will get the
RowDefinitions
collection from theGrid
(which in this case is the sender but you just as easily have usedFindName
to get a named grid. Then it loops adding 20RowDefintion
instances ot the collection.