Accessing Controls in a Template to Databind Properties

Posted on: Wed Jun 18 16:12:49 -0700 2008. Updated on: Sat Jun 21 00:23:22 -0700 2008.
Category: Silverlight

So, lets say that you created a silverlight button control and you are overriding the default template with your own defined template. Now, let's say you need to databind, say, the TextBlock text property on an event, but you cannot acces the TextBlock directly because it is within a template. Solution: Simply set the TextBlock Text property to:

{Binding ObjectPropertyName}
and then in the code behind in your event that will bind the data, go:
Button.DataContext = ObjectWithDefinedProperties;

Comments:

Add a Comment:

simple_captcha.jpg
(human authentication)


Ads

Categories

About

Random foliage

This website is meant to be a reference for ASP Dot Net developers. The entries are a compilation of things I've figured out how to do and that I deem useful to keep of track for future reference. Assumptions: web development with: C Sharp (vb sucks), visual studio 05/08, .net 3.5, meant for programmers. Written by: James Reategui.