WPF/Silverlight DataBinding to interface property (with hidden implementation)

Posted by Dave on Stack Overflow See other posts from Stack Overflow or by Dave
Published on 2010-05-22T14:28:16Z Indexed on 2010/05/22 14:30 UTC
Read the original article Hit count: 118

Filed under:
|
|
|

I have the following (C#) code

namespace A
{
  interface IX { bool Prop { get; set; } }
  class X : IX { public bool Prop { ... } } // hidden implementation of IX
}

namespace B
{
  ..
  A.IX x = ...;
  object.DataContext = x;
  object.SetBinding(SomeDependencyProperty, new Binding("Prop"));
  ..
}

So I have a hidden implementation of an interface with a property "Prop" and I need to bind to this property in code.

My problem is that the binding isn't working unless I make class X public.

Is there any way around this problem?

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf