1
Vote

System.Reflection.AmbiguousMatchException in designer

description

[Edit : I replaced the original bug report with the REAL issue description after investigations]
 
I have longly investigated and found the problem.
 
The Visual Studio designer does not support the Title property "overriding" with another object typed property.
I have also tried to put a call to Window.TitleProperty.OverrideMetaData(...) method in the static constructor but it definitively crashes the designer.
 
Here is my solution :
Separate the Title string property and TitleContent object property for the objects that have to be in the Window header.
I put a Stackpanel in the Window header with a TextBlock showing the native Title property value and a ContentControl for other stuff.
The both Visible properties are set to Collapsed using WPF triggers when there is nothing to show (no text or no content).

comments

AEstienne wrote Jan 28, 2011 at 9:57 AM

The problem seems a bit more annoying :
I have simply commented the previous controls (both TextBlock and Slider).
Now, the exception is not thrown directly when window is opened but as soon as I set any property of the window (eg. Height, Width, Title).

I am not at ease with XAML property binding, so any help would be welcome.

AEstienne wrote Feb 1, 2011 at 8:53 AM

I have longly investigated and found the problem.

The Visual Studio designer does not support the Title property "overriding" with another object typed property.
I have also tried to put a call to Window.TitleProperty.OverrideMetaData(...) method in the static constructor but it definitively crashes the designer.

Here is my solution :
Separate the Title string property and TitleContent object property for the objects that have to be in the Window header.
I put a Stackpanel in the Window header with a TextBlock showing the native Title property value and a ContentControl for other stuff.
The both Visible properties are set to Collapsed with when there is nothing to show (no text or no content).

wrote Feb 1, 2011 at 10:32 AM

wrote Feb 1, 2011 at 10:33 AM

wrote Feb 13, 2013 at 7:39 PM