views:

132

answers:

2

I have a custom text box control which raises a routed event when its TEXT property changes. This text property is data bound to a property on our view-model object.

When I place this control on a TabControl page or Expander control, it appears as if data binding only occurs when the control becomes visible for the first time, therefore I never receive any of the routed events until I swap to the tab the control is on or expand the expander.

Is there any way I can force data binding to occur before the control is shown?

A: 

Not very likely. WPF is a fairly efficient framework and won't do any work that it doesn't absolutely have to. This includes scenarios like data binding. Why bother exercising a collection for a control that might not ever be shown?

JaredPar
A: 

Sounds like you relying on the data binding to genreate the routed event is the wrong approach. Instead you need to have your Model or ViewModel generate an event when the text is modified and then you watch this event from an appropriate place in your View.

Phil Wright
I agree. I should probably approach this in another way. Thanks.
Andrew Jackson