c# - 如何在 XAML 中的 'created' 代码隐藏中访问控制

标签 c# .net wpf xaml

我有一个在 XAML 中“创建”的控件,我想通过代码隐藏访问它。

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

this.PendingAuthsFrame1.Text = "334";

但是,我在上面的第二个语句中遇到构建错误,指出 MyApp.MainWindow 不包含“PendingAuthsFrame1”的定义并且没有扩展方法.... 它一直在继续,但我猜你明白了。

我错过了什么或做错了什么?

最佳答案

使用 x:Name 而不是 Name。这应该可以解决问题。

关于c# - 如何在 XAML 中的 'created' 代码隐藏中访问控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13569782/

相关文章:

c# - 如何通过列名获取Excel中的列号

C# 从 Windows Azure 存储下载返回空文件,没有任何异常

wpf - mvvm 中 crud 逻辑应该在哪里实现?

c# - 将文件上传到不同的服务器

c# - XPath : Get nodes where child node contains an attributeHow to select node that have and attribute and whose parent have another attribute in c#

c# - 继承和扩展方法

c# - 我可以延长 session 或实例或控制GC的生命周期吗?

c# - 序列不包含元素

c# - 在连接的节点之间画线

c# - 我如何测试 Relaycommand?