Skip to main content

Microsoft Silverlight

Answered Question Working with properties in user controlsRSS Feed

(0)

softimagexsizer
softimag...

Member

Member

0 points

2 Posts

Working with properties in user controls

Hey: I am not sure how to ask this question as I am a serious beginner to SL. Please feel free to point me toward some tutorials or chapter of some book, or something :) I have a UserControl that contains a navigation menu button. (I followed Jesse tutorial on how to create user controls and add them to a project). The "menu button" is simply a Border with a TextBlock in it, and when you mouse over it it highlights. Here's the problem: When I originally created the textblock in xaml, I set Text to "HOME" (Text="HOME"). I built the logic for the button and storyboards and put it all in a new user control. Now when I add that user control to my mainpage it says "HOME". When I add another one, IT says "HOME". What is a good way to change the Text property of different instances of the user control? I hope that makes sense. If it does not, please let me know. Thanks

Ardman
Ardman

Contributor

Contributor

3436 points

947 Posts

Answered Question

Re: Working with properties in user controls

 Create a public property in your UserControl and then Bind the TextBlock to the property.

So, in your TextBlock XAML, change the Text to Text="{Binding PropertyName}".  This will bind the data to the property.  You can then set your property to whatever value you like.

softimagexsizer
softimag...

Member

Member

0 points

2 Posts

Re: Re: Working with properties in user controls

Thanks a lot. I will give it a try.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities