views:

31

answers:

1

Hi,

I am trying to bind a label 2 (or more!) fields in a dataset in Silverlight 4. I get a localized string out of a resource file and do a String.Format on it like so:

<TextBlock Name="lblTotals" Text="{Binding TotalItems, StringFormat='You need \{0\} items and \{1\} products.'}" />

This works fine with 1 item but there's no way of doing multiple binds in SL4 it seems.

I found some blog posts on how to bind a single element to multiple fields but it does not seem to support the String.Format part which is critical.

The last caveat is that it is bound to an ObservableCollection, so when these fields change in the data the UI must update too.

Any suggestions? Thanks!

A: 

I found a solution here using a converter and binding to the whole object and passing in the string as a converter param.

Then the totals did not update when the grid values updated (despite being linked to OnPropertyChanged) - this was the solution hack here.

Rodney