WPF Error 40 BindingExpression path error: property not found on 'object'

后端 未结 9 605
一整个雨季
一整个雨季 2020-11-27 16:04

I\'m banging my head on my desk with this binding error.. I have checked several of the postings for the BindingExpression path error and cannot see anything t

相关标签:
9条回答
  • 2020-11-27 16:24

    This error may also occur when you were previously trying to bind inaccessible or non-existing Enumerable instance using XAML property <ItemsSource>

    When you correct the ItemsSource with the correct value XAML doesn't automatically reilitialize the collection of items.

    So when I was using the ListBox UI - list representation I faced this in the properties:

    Deleting all the items in collection and correcting ItemSource value was the key.

    0 讨论(0)
  • 2020-11-27 16:26

    After looking at Shahid's answer, I noticed in my case that I had set the DataContext to a reference in the Loaded event instead of in the constructor. Moving it to the constructor fixed the issue.

    0 讨论(0)
  • 2020-11-27 16:30

    I had the same problem and in my case I was using bool instead of Boolean. As soon as I changed it, it's working as expected.

    0 讨论(0)
  • 2020-11-27 16:31
    public Window()
    {
          this.DataContext = this;
          InitializeComponent();
    }
    public string Name {get;}
    //xaml
    <TextBlock Text="{Binding Name}"/>
    

    Properties Name should be public and { get; }

    0 讨论(0)
  • 2020-11-27 16:33

    I got this error and my case was as simple as setting the String I was binding to from private to public.

    Careless mistake writing my backing field.

    0 讨论(0)
  • 2020-11-27 16:38

    I had same problem because class of object from which I was pulling out data didn't have get; and set; on its properties.

    this didn't work:

    public string Name;
    

    but this worked:

    public string Name{ get; set; }
    
    0 讨论(0)
提交回复
热议问题