I have the following (C#) code
namespace A
{
public 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?
I believe you are doing this in Silverlight, because binding to not public members is not possible there. However it is in WPF.
So for Silverlight you should make your class public.