Boolean DP and Binding
I need to bind bool property of model to bool dependency property of control. If I wrote this in XAML in short form, like this:
<Button IsEnabled="{Binding Path=Loaded}"/>
I got a build error. OK, next I tried to use full form:
<Button>
<Button.IsEnabled>
<Binding Path="Loaded"/>
<Button.IsEnabled>
</Button>
That's works fine, but form designer in VS still showed an error and ain't worked. Is there any solution?
[1027 byte] By [
AndrewVK] at [2007-12-29]
Both forms look correct to me. What was the build error (including inner exception)?
Could it be because Loaded is an event (not a property)? Did you mean IsLoaded instead?
Error in short form:
The 'IsEnabled' attribute is invalid - The value '{Binding Path=Loaded}' is invalid according to its datatype 'http://schemas.microsoft.com/winfx/2006/xaml/presentation:frlrfSystemBooleanClassTopic' - The Enumeration constraint failed.
Error in full form:
Property 'IsEnabled' does not support values of type 'Boolean'.
Loaded is a property of type bool. (Yes, IsLoaded is more readable :) )
Strange effect - after I restarted the VS, build with short form completed successfully, and designer show only warning, not error with "Whoops!" picture. Full form still make designer unworkable.
Sounds to me like the designer doesn't know about WPF's markup extensions. Or got into a state where it forgot about them; rebooting VS restored its memory. In short - it's a designer issue, not WPF. Try the Cider forum (I presume you're using the Cider designer).