Hi all,
I have a problem with bindings in wpf. I've discovered a strange problem. I have class ConfiugrationStringBuilder which inherits from DbConnectionStringBuilder. When I do smth 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 binding to xaml for txtBox
<TextBox Name="txtBox" Text="{Binding Path=Directory}"></TextBox>
The problem is that above code doesn't work. I can't bind to my class property, but i can bind to public properies of base DbConnectionStringBuilder.
And the most funniest thing is that when i remove inheritance from DbConnectionStringBuilder
so my code looks like this
public class ConfiugrationStringBuilder
{
public string Directory { get;set; }
}
In this case the above binding works well. I can't find any info about such cases and why in this case binding doesn't work? can somebody explain such behavior?
While I was writing the qusetion I tried to investigate what is a problem. And discovered that DbConnectionStringBuilder has indexer, so when try to bind to Path=Directory
on backstage it does builder["Directory"]
not builder.Directory
. Anyway, can somebody tell me why it is doing so?