views:

40

answers:

1

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?

+1  A: 

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.

ligaz
Yep, that violated the Access rules for Silverlight. What's the point of blocking private/protected/internal reflection if users can just bind to those values and set/get them?
JustinAngel