Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Error in VS (2015 SP1) designer for a 4.5.2 project when *not* running project code

$
0
0

I got this annoying error in my designer after upgrading a project to .Net 4.5.2:

Error:
The property "SelectionFiltersEffective" is not a DependencyProperty. To be used in markup, non-attached properties must be exposed on the target type with an accessible instance property "SelectionFiltersEffective". Forattached properties, the declaring type must provide static"GetSelectionFiltersEffective"  and "SetSelectionFiltersEffective" methods.

The failing xaml was in a TextBlock style as follows:

<Style TargetType="TextBlock"><Setter Property="Visibility" Value="Hidden" /><Style.Triggers><Trigger Property="Ack:AcknowledgementSelection.SelectionFiltersEffective" Value="false"  ><Setter Property="Visibility" Value="Visible"/></Trigger></Style.Triggers></Style>

As you can see, the property in question is an attached property:

        /// <summary>
        /// Keep track of selection filters.
        /// (Whether they are currently in effect or not)
        /// </summary>
        public static   DependencyProperty SelectionFiltersEffectiveProperty
            =           DependencyProperty.RegisterAttached("SelectionFiltersEffective",
            typeof(bool),
            typeof(AcknowledgementSelection),
            new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits));
        public bool SelectionFiltersEffective
        {
            set { SetValue( SelectionFiltersEffectiveProperty, value ); }
            get { return ( bool ) GetValue( SelectionFiltersEffectiveProperty ); }
        }

So it turns out the error happens only when I am *NOT* running project code.  (I imagine that is the opposite experience that people would normally expect, assuming that in many cases, the project code does fancy things that aren't supported in the context of the designer.)

So what is the deal?  Is the xaml designer being more picky on me when its *not* running my code?  Is it looking for the presence of the static Get/Set methods that don't actually need to be there when the project code is enabled?

Anyway, the only workaround I've found are to either enable project code for the xaml designeror go back to 4.5.

As a side, I have actually tried to persue the ("no-project-code") suggestion from the designer but it doesn't work (as follows):

        public static void SetSelectionFiltersEffective(DependencyObject p_Element, bool p_Value)
        {
            p_Element.SetValue(SelectionFiltersEffectiveProperty, p_Value);
        }
        public static bool GetSelectionFiltersEffective(DependencyObject p_Element)
        {
            return (bool)p_Element.GetValue(SelectionFiltersEffectiveProperty);
        }


I think the "no-project-code option" in still very much a beta feature, is that not so?  Are these XDesProc bugs (for "no-project-code") things that are likely to be fixed if I report them via professional support?

 


David Beavon


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>