Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Binding difference between user and custom control
1 replies. Latest Post by tyrel on August 12, 2009.
(0)
tyrel
Member
16 points
25 Posts
08-12-2009 3:46 PM |
I have a problem with a control I created to show an icon plus some text, disable/enable, change the text displayed and handles mouse over/clicks etc. In Silverlight 2 it worked fine, but now in Silverlight 3 the binding for the user control no longer works. I created a test project that has both a regular and custom templated control in it. The templated control using <TextBlock Text="{TemplateBinding Text}" /> works fine, while the user control using <TextBlock Text="{Binding Text}" /> does not. This used to work in 2.0. So am I missing something with the binding for the user control?
The Text property is a DependancyProperty and is defined the same way for both the user and custom control.
Link to the test project: https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=UserControlBinding&ReleaseId=3100
08-12-2009 4:00 PM |
Adding DataContext = this; to the constructor makes the text show up, so am I to assume that you have to do that for user controls if you want to use binding the way I am? Or am I still missing something? Also I am pretty sure I tried that in the real world example and it did not work correctly.