0

i have a TextBlock Text target with a business object as a Binding Source, and this binding works fine with updates to the business object property propagating to the GUI, with the help of INotifyPropertyChanged

Aim

The default behavior of such a binding is to replace the contents of the control such that say a second update to the business property will overwrite the display of the first update.

I would like the UI to display the first update, then append the second update and so forth, how might that be possible ?

An Implementation?

  1. Im not familiar with even the basic arsenal of wpf controls, would this be easier with a control other than TextBlock?

  2. Or is it possible to do such binding with TextBlock?

It is undesirable for the business object to remember / store the previous updates. I have already tried to use the object parameter in IValueConverter Convert method, but that does not work...

H.B.
  • 166,899
  • 29
  • 327
  • 400
Cel
  • 6,467
  • 8
  • 75
  • 110

1 Answers1

1

you can use the mvvm pattern and take a viewmodel to collect the propertychanged event data from your business object.

in this viewmodel create a

ObservableCollection<string>_myUpdateList = new ObservableCollection<string>();

proeprty to collect the data.

on UI(View) side i would take a itemscontrol, listbox or something like this and bind the ItemsSource to your ObservableCollection.

thats all. :)

blindmeis
  • 22,175
  • 7
  • 55
  • 74
  • sweet! do you happen to know how i could make the listbox wrap long lines? i.e. i used to be able to do `textBlock1.TextWrapping = TextWrapping.WrapWithOverflow;` but am now to `listBox1.ItemsSource = _myUpdateList;` – Cel Sep 14 '11 at 13:52
  • look at http://stackoverflow.com/questions/146269/change-wpf-datatemplate-for-listbox-item-if-selected for example. you can modify the itemtemplate textblock with WrapWithOverflow. if this did not work, just ask a new question on SO – blindmeis Sep 14 '11 at 17:37