c# - WPF - How to databind subclass property correctly -
I have a very stupid problem with databanding in WPF. I have a custom exception type
public class MyException: exception {public class throwning method {public class registered mode} {string registered name for public reading; // ...} public read-only registered method regMethod; // ...} Public Read-Only ThrowingMethod Throw Method; OK, now in my wpf window, I public partial class exception display: window {Private Readonly IEnumerable & lt; MyException & gt; exception; Public exception display (IEnumerable & lt; MyException & gt; exception) {InitializeComponent (); This.exceptions = exceptions; } Private Zero Windows_Loaded_1 (Object Sender, RoutedEventArgs e) {DataContext = this.exceptions.First (); }} And I have two labels in XML:
& lt; Label name = "message" content = "{binding message}" /> & Lt; Label name = "RegMethod" content = "{binding path = throwingMethod.regMethod.registeredName, mode = thwave}" /> Strangely, the message ties properly, but the second label remains empty and it does not seem to have anything. When I manually set the values by code in Window_Loaded_1, it works fine, so the objects are started correctly.
Why throwingMethod.regMethod.registeredName is not bound, am I doing something wrong here?
Thank you!
You can not force the properties of a square field.
You have to write at least:
throwing public throning method (get); Private set; } Registered Name and regMethod are the same. The next question is that if you need to update then the INotifyPropertyChanged interface will be useful.
Comments
Post a Comment