Skip to main content
Home Forums General Silverlight New Features in Silverlight 3 Dynamic DataTemplate!
1 replies. Latest Post by Martin Kruszynski on November 4, 2009.
(0)
jimijani...
Member
3 points
8 Posts
10-21-2009 6:00 AM |
i am making an application with mvvm architecture. i have a view which consist of a list( of borders which inturn contains textblock). i need to template the contents of the list based on contents of the textblock , i.e if the text property of TextBlock contains a substring = "system" , i want the Border's background to be red . how can i do this . thanks Jamal.
Martin K...
15 points
27 Posts
11-04-2009 6:56 PM |
You can make ItemTemplate with a custom control with some visual states. The control has f.e Text property which you bind (control would contain TextBlock in its template which you could bind to your control Text property). When binding value has changed, you change control visual state (in callback of dependency property TextProperty of your control).
If you have complex conditions (f.e contains), you probably should write code in your control. If you have to display different views for different data values in a simple way, you can use DataStateBehavior or DataStateSwitchBehavior from http://expressionblend.codeplex.com/