Skip to main content
Home Forums Silverlight Programming Programming with .NET - General User control binding
2 replies. Latest Post by mpellegrin on June 12, 2008.
(0)
mpellegrin
Member
58 points
19 Posts
06-10-2008 6:08 PM |
Previously (Beta1), I was able to create a couple of user controls with dependency properties, place them in page.xaml, bind one dependency property to another, set the datacontext in the code behind and I was off to the races. However, since I upgraded my project to Beta 2 I get a "Value does not fall within expected range" exception.
Is this a bug/feature? Is there a workaround?
I can't post my exact code, but if my premise is not clear, I could make a short example.
Yi-Lun L...
All-Star
25052 points
2,747 Posts
06-12-2008 12:58 AM |
Unfortunately this is a bug... What you can do is to create a helper class with intermediate properties. Something like this:
public class Helper : INotifyPropertyChanges
{
public string Name { get; set; }
}
<TextBlock x:Name="tb1" Text="{Binding Name}"/>
<TextBox x:Name="tb2" Text="{Binding Name, Mode=TwoWay}"/>
Helper helper = new Helper();
tb1.DataContext = helper;
tb2.DataContext = helper;
06-12-2008 9:30 AM |
This is exactly what I wound up doing. In fact, now that i have implemented this I prefer this method to binding the controls directly to each other as it seems to eliminate some circular dependencies I was encountering.
Thanks for the response.