Dependency Property Set Priority: CodeBehind vs. XAML

Posted by LukePet on Stack Overflow See other posts from Stack Overflow or by LukePet
Published on 2010-04-28T13:08:19Z Indexed on 2010/04/28 13:13 UTC
Read the original article Hit count: 370

When I initialize a control property from code, the binding to the same property defined on XAML don't work. Why?

For Example, I set control properties on startup with this statements:

myControl.SetValue(UIElement.VisibilityProperty, DefaultProp.Visibility);
myControl.SetValue(UIElement.IsEnabledProperty, DefaultProp.IsEnabled);

and on xaml I bind the property of myControl in this way:

 IsEnabled="{Binding Path=IsKeyControlEnabled}"

now, when the property "IsKeyControlEnabled" changes to false, myControl remains enabled (because it's initialize with true value).

How can I do?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about xaml