views:

27

answers:

1

Hi I have an Combobox which is poplated with data that is time sensitive.
My setup is a bit hard to explain so lets assume that the Combobox has a itemtemplate containing a textblock.
The textblock is databound to a property returning DateTime.Now, I would like to rebind the value of the textblock (not the whole combobox).
Is there a way of looping through the items to update them or something like that or some other magical function that can rebind the items (without rebinding the whole Combobox).

Cheers
/Jimmy

+1  A: 

Is there a reason you can't just raise an INotifyPropertyChanged event in the bound object(s) for the property that is bound to the textblock? As long as you don't raise INotifyPropertyChanged on whatever collection is bound to the combobox ItemsSource this should work I think.

Steve Willcock
What is the best way of doing that? I need to do it bascically every minute or perhape every two minutes, should I use a timer in the object or simply loop over the itemsource and run some kind of method that raise INotifyPropertyChanged?
Jimmy Engtröm
Either way would work - I'd probably advise against putting a timer inside each of the individual objects in the ItemSource as you can probably manage with a single timer object and a loop. If the ItemSource is a property of some parent View Model object then you could add a single timer to the parent object that calls a method on each of the child objects in turn. If the ItemSource is not bound to a property of a parent View Model object in this way then I assume you're not using an MVVM approach so a timer in code-behind to loop over the itemsource and raise the event from there should be ok
Steve Willcock
Worked great =) Thanks
Jimmy Engtröm