tags:

views:

25

answers:

2

Hi,

I have a very interesting issue and i have been breaking my head on it since a long time.

I am new to WPF and related things like MVVM and all.

I have a window in which i place a user control which hosts a TabControl inside it.

This tab control has Custom Radio Button and Combo boxes which expose few Dependency Properties, Now while these custom controls are loaded author checks for the values and does 'something particular' which is intended behavior. However in my case while the control is being loaded the DPs have null values. I see the DP property changed events being fired post Load of that control only in my case. It works okay on other windows.

This is kind of strange to me as I would expect that the DPs would be bound to related values before the control gets loaded, but i dont see that behaviour here.

I have read on MSDN that the DPs should be set properly before load event, and in a sample application i see it behaving as per MSDN.

Binding is happening properly as there are no errors in out put window + I get the DP - Property changed events as well, but this happens only after load (I dont know why??)

Any help would really be appreaciated.

A: 

Your DP values are being set before loading, but they're being set to Bindings, which aren't evaluated until after the UI loads (and so don't provide values to the DP). Values set directly (in XAML usually) are applied to the DP immediately during load because the value is guaranteed to be available. Bindings can often depend on things like DataContext or other visual tree elements (ElementName or RelativeSource) which may not be available until after loading is completed so the Binding evaluation process happens later.

John Bowen
But John all these values are available as local properties and the data context is also being set before the control can get loaded.. similar approach works fine on other windows why not mine??
v703218
A: 

After I checked the Output traces i get following for all the bindings for the first time I open the dialog

Cannot retrieve value using the binding and no valid fallback value exists; using default instead

I am not sure why all of them are not being able to be found??? Is this a Timing issue, I am using DATA context property value inheritance every where.....

v703218