سؤال

Let's say I have class with Name property. I'd like to bind collection of objects of this class to Silverlight 3 ListBox. But I want to show items like that:

  • "Some dynamic str " + Name (object property)
  • "Some dynamic str " + Name (object property)
  • "Some dynamic str " + Name (object property)

How can I achieve this without use of converters?

Can I use function for each item to format display value?

هل كانت مفيدة؟

المحلول

Silverlight 3 does NOT support the StringFormat Binding option: Does Silverlight support StringFormat in binding?

You could use a ValueConverter but if you do not want that as mentioned in your question you might want to consider either:

Changing the ViewModel property so it returns the correct text or

adding extra TextBlocks in the View that prefix the text with "Some str".

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top