views:

124

answers:

2

Hi!

I have many dependency properties in my WPF usercontrol and many of them are set directly in XAML. Among these are ItemsSource and Value (my custom properties). The problem is that initial Value selects a concrete item in ItemSource. But to achieve this, ItemsSource must be set first. While debugging I realized that ValueChangeCallback method runs sooner than ItemsSourceCallBack. Can I influence this? How can i tell ValueChangeCallback to wait until ItemsSource is set?

Thank u very much.

A: 

No way that I know of. Instead, you might want to set some kind of flag in your ValueChangeCallback if the ItemsSource is not yet set. Then, when the ItemsSource is set, check that flag and update the Value again.

HTH, Kent

Kent Boogaart
yeah thank you very much, that's what I've been thinking about, but I was worried, that there is a more elegant way of doing this.I really appreciate your quick response.
PaN1C_Showt1Me
+1  A: 

Initialise the ValueChangedCallback the first time the ItemsSourceCallBack is executed. That way you avoid the unnecessary ValueChanged calls before the "right" ItemsSource is set.

David Schmitt