简体   繁体   English

如何在XAML中“创建”的Code Behind中访问控件

[英]How to access control in Code Behind that was 'created' in XAML

I have a control I 'created' in XAML that I want to access through the Code Behind. 我在XAML中创建了一个控件,我希望通过Code Behind访问它。

<wincontrols:LiveTileFrameElement Name="PendingAuthsFrame1" Text="Pending" />

this.PendingAuthsFrame1.Text = "334";

However, I get a Build Error on the second statement above stating MyApp.MainWindow does not contain a definition for 'PendingAuthsFrame1' and no extension method.... it keeps going but you get the idea I'm guessing. 但是,我在上面的第二个语句上得到了一个Build Error,说明MyApp.MainWindow does not contain a definition for 'PendingAuthsFrame1' and no extension method....它继续进行但是你得到了我猜的想法。

What am I missing or doing wrong? 我错过了什么或做错了什么?

Use x:Name instead of Name . 使用x:Name而不是Name That should do the trick. 这应该够了吧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从后面的代码访问XAML中的未命名控件 - Access unnamed control in xaml from code behind 如何从 xaml 中的 ItemTemplate 访问在代码中定义的用户控件的依赖项属性? - How can I access a dependency property of a user control that was defined in code behind from a ItemTemplate in xaml? 如何从另一个in-behind xaml代码中访问变量in-behind xaml代码 - how to access variables in-behind xaml code from another in-behind xaml code 如何使用XAML和后面的代码序列化WPF用户控件 - How can I serialize wpf user control with xaml and code behind 如何在后面的代码中访问控件库? - How to access a control templace in code behind? 如何访问位于DataTemplate标签的文本框控件 <phone:PanoramaItem.HeaderTemplate> 从代码开始-在后面(MainPage.xaml.cs) - How to access textbox control located in DataTemplate tags of <phone:PanoramaItem.HeaderTemplate> from code - behind (MainPage.xaml.cs) wpf xaml绑定到后面的代码中创建的对象 - wpf xaml binding to object created in code behind WPF - 在XAML中绑定到后面的代码中创建的对象 - WPF - Binding in XAML to an object created in the code behind 如何在另一个XAML文件中访问ResourceDictionary属性后面的代码? - How to access a code behind property of ResourceDictionary in another XAML file? 如何在文件(xaml.cs)后面的代码之外访问样式? - How to access a Style outside the code behind file (xaml.cs)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM