Skip to main content

Microsoft Silverlight

Answered Question Binding difference between user and custom controlRSS Feed

(0)

tyrel
tyrel

Member

Member

16 points

25 Posts

Binding difference between user and custom control

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

tyrel
tyrel

Member

Member

16 points

25 Posts

Answered Question

Re: Binding difference between user and custom control

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.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities