Silverlight : Grow your own controls

January 13, 2009 17:50 by tim

We had an issue on an early version of a silverlight app we wrote.  the whole thing was a banner which was fed data from a SharePoint list.  The site itself was multi-lingual so the same sentence coudl be one and half times as long in, say, the German version as it was in the English version

Being a data-binding kind of person (?), I opted to use Silverlights inherently powerful DataBinding features and have it fill the text from a custom object I got from the list.  However, since th controls were coded into the xaml, the size of the box was causing truncation in some instances, forcing us to set it to be the width of the logest piece of text we would ever encounter, not a very clever solution but good enough for the dev site

Re-visiting the code for live, I had a brain-wave.  I knew that silverlight could handle the dynamic sizing, Blend was all over it and the area was expanding and contracting as needed.  So, i broke it out of the xaml, turned it into a usercontrol, and then added it to the canvas at run time, after i'd set the text from the data.  Then, when the control renders, it's the correct size for the text it contains :¬)

Job done :¬)


Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Comments

October 3. 2009 07:31

Congrats Smile

games

Add comment


 

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

September 3. 2010 14:02

Calendar

September 2010
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

Tags