FrameworkElement.Name problem

情到浓时终转凉″ 提交于 2019-12-01 16:29:20

The Name property generally follows the rules of C#/VB.NET identifiers (i.e. fields). Based on the documentation:

The string values used for Name have some restrictions, as imposed by the underlying x:Name Directive defined by the XAML specification. Most notably, a Name must start with a letter or the underscore character (_), and must contain only letters, digits, or underscores.

Based on the parameter you are passing (i.e. title), it seems like you may violate that. But you'd have to give some specific examples to be sure.

Of course, moments after posting this I realised what's going on.

Because FrameworkElement.Name is used for creating object references, you have to ensure that the string contains only valid chars for an object instance variable name.

Use Title or another plain text property instead, unless you really want to set the x:Name property for referencing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!