问题描述
大家好,
在我的应用程序中,我有一个longlistselector,它是动态填充的.它有一个按钮,我想从后台代码访问其名称,但不幸的是我不能.请帮助.
In my App I have a longlistselector which is populated dyamically. It has a button whose name i want to access from background code, but unfortunately i am not able to. Kindly help.
例如:
< phone:longlistselector .... Itemsource = {Binding myList}>
<phone:longlistselector .... Itemsource={Binding myList}>
< DataTemplate ....>
<DataTemplate ....>
<网格....>
<Grid ....>
<按钮x:name ="BttnName"; />
<Button x:name="BttnName" />
</网格....>
</Grid ....>
</DataTemplate ....>
</DataTemplate ....>
</phone:longlistselector ....>
</phone:longlistselector ....>
我无法从C#代码访问按钮的名称.而且我还希望当我们单击按钮时,与网格相关的所有值对我来说都是可访问的.
I am not able to access name of button from c# code. And I also want that when we click on the button all the values associated with the grid is accessible to me.
谢谢.
Abhishek
推荐答案
有一些链接可以解释如何访问ItemTemplate或DataTemplate中包含的控件:
There are a few links out there explaining how to access controls that are contained inside an ItemTemplate or DataTemplate:
如何访问放置在内部的控件WP7中的ListBox ItemTemplate
Silverlight DataTemplate中的访问元素
希望这会有所帮助,
标记
Hope this helps,
Mark
这篇关于如何在longlistselector内部的c#中访问按钮的名称.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!