FrameworkElement.Name problem

后端 未结 2 910
天命终不由人
天命终不由人 2021-01-17 23:38

I am attempting to set the Name property of a Page in the constructor:

public partial class PageListView : Page
{
    public PageListView(string title)
    {         


        
2条回答
  •  广开言路
    2021-01-18 00:13

    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.

提交回复
热议问题