Usage of own defined DependencyProperty of type bool? failes
-
Wednesday, May 23, 2012 7:27 AM
Hi,
I have the following definition in a class librarypublic static bool? GetGeneralUserFlag ( DependencyObject obj ) { return (bool?)obj.GetValue(GeneralUserFlagProperty); } public static void SetGeneralUserFlag ( DependencyObject obj, bool? value ) { obj.SetValue(GeneralUserFlagProperty, value); } public static readonly DependencyProperty GeneralUserFlagProperty = DependencyProperty.RegisterAttached("GeneralUserFlag", typeof(bool?), typeof(FrameworkExtension), new PropertyMetadata(null));I tried to use it in XAML as follows:
<StackPanel xmlns:cle="using:ClassLibrary.Extensions" cle:FrameworkExtension.GeneralUserFlag="true" />
Compile goes ok, on execution:
An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in XXX.exe but was not handled in user code WinRT information: Failed to create a 'Windows.Foundation.IReference`1<Boolean>' from the text 'true'. [Line: 27 Position: 190] Additional information: Unspecified error
All Replies
-
Thursday, May 24, 2012 2:57 AMModerator
Hi NRN,
Does this work for you if you use a non-nullable bool? If you do the same in your main app rather than in a class library?
Setting nullable properties I custom controls is not a supported scenario. See this thread for a previous discussion of a similar issue.
--Rob
- Marked As Answer by Min ZhuMicrosoft Contingent Staff, Moderator Wednesday, May 30, 2012 2:18 AM


