Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Working with properties in user controls
2 replies. Latest Post by softimagexsizer on November 8, 2009.
(0)
softimag...
Member
0 points
2 Posts
11-06-2009 7:36 PM |
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
Contributor
3172 points
881 Posts
11-07-2009 5:32 AM |
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.
11-08-2009 1:55 AM |
Thanks a lot. I will give it a try.