-1

While editing a WPF custom control the design view in Visual Studio 2019 ran into this error:

enter image description here

(entire exception details down below).

Web searches have turned up nothing useful for RuntimeVisibility, although there are other similarly worded "is not a valid value" messages they seem quite varied. I can't even find the term "RuntimeVisibility" almost at all related to WPF.

So I tried to debug the VS2019 designer process by attaching to XDesProc in a separate VS2019 instance. By enabling trapping of all exceptions it would indeed break when the control in question was loaded into the designer. But it isn't failing in any user-level code; the problem emerges from somewhere deep inside the framework and the debugging information at that stack frame is meaningless to me.

I'm looking for a methodology or advice to track down the root cause of this problem. While it's annoying in the designer I'm more concerned if this could lead to an error at runtime. As noted, the mysterious RuntimeVisibility property doesn't seem like a designer-specific issue.


Full exception info:

XamlParseException: '' is not a valid value for property 'RuntimeVisibility'.

StackTrace

   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter)
   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlObjectWriter objectWriter)
   at System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(DependencyObject container, IComponentConnector componentConnector, IStyleConnector styleConnector, List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField)
   at System.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List`1 affectedChildren)
   at System.Windows.StyleHelper.ApplyTemplateContent(UncommonField`1 dataField, DependencyObject container, FrameworkElementFactory templateRoot, Int32 lastChildIndex, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate)
   at System.Windows.FrameworkTemplate.ApplyTemplateContent(UncommonField`1 templateDataField, FrameworkElement container)
   at System.Windows.FrameworkElement.ApplyTemplate()

InnerException: '' is not a valid value for property 'RuntimeVisibility'.


   ArgumentException: '' is not a valid value for property 'RuntimeVisibility'.

   StackTrace

      at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
      at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)

   InnerException: None
StayOnTarget
  • 11,743
  • 10
  • 52
  • 81

1 Answers1

0

After I gave up on debugging XDesProc I resorted to commenting things in/out in the XAML just on a hunch to see if I could locate the problem. I didn't specifically know that it originated in the XAML but that turned out to be the case.

By working "outside-in" (meaning, comment out almost the entire body of the XAML, and then gradually add things back in) I was able to narrow it down to one line that, when removed, also eliminates the error:

        <Canvas
            ToolTipService.IsEnabled="{c:Binding ShowToolTip}"
            Visibility="{c:Binding IsVisible}"
            >

where c:Binding refers to:

xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding"

(https://github.com/Alex141/CalcBinding)

When the Visibility attribute is removed, the error goes away.

What c:Binding is doing here is automatically converting between a bool property in the viewmodel and a proper Visibility value. This normally works fine, but I can just replace it with with a normal binding and a converter to work around the problem.

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81