Strange wpf binding

I have a problem with bindings in wpf. I discovered a strange problem. I have a ConfiugrationStringBuilder class that inherits from DbConnectionStringBuilder. When I do something like this

public class ConfiugrationStringBuilder : DbConnectionStringBuilder
{
  public string Directory { get;set; }
}

ConfiugrationStringBuilder builder = new ConfiugrationStringBuilder(connStr);

builder.Directory = "d:\dir"; //my property

txtBox.DataContext = builder;

then add xaml binding for txtBox

<TextBox Name="txtBox" Text="{Binding Path=Directory}"></TextBox>

The problem is that the above code does not work. I cannot bind to a class property, but I can bind to the public functions of the DbConnectionStringBuilder base.

And the funny thing is that when I remove the inheritance from DbConnectionStringBuilder

so my code is as follows

public class ConfiugrationStringBuilder
{
  public string Directory { get;set; }
}

In this case, the above binding works well. I can not find information about such cases and why in this case the binding does not work? can anyone explain this behavior?

qusetion, , . , DbConnectionStringBuilder , Path=Directory builder["Directory"] not builder.Directory. , - , ?

+3
1

-Magic Master-Detail (. ). , IEnumerable, TextBox , - , .

, , , DBConnectionStringBuilder , ( ).

+3

Source: https://habr.com/ru/post/1767148/


All Articles