AmbiguousMatchException during PropertyGrid population with shadowed Property
Issue: AmbiguousMatchException during PropertyGrid population with shadowed Property
The System.Reflection.AmbiguousMatchException occurs when the Syncfusion PropertyGrid attempts to inspect an object that contains shadowed or hidden members via inheritance. Specifically, when a derived class declares a property using the new keyword to hide a member of the same name from a base class, the PropertyGrid’s internal reflection logic fails to resolve which member to bind to. This results in a crash when the control attempts to generate the property list or access the metadata of the affected property.
Is there any workaround without changing the classes to allow shadowed properties?
/// <summary>
/// Concrete implementation of <see cref="IFirstExample"/>.
/// </summary>
publicclassFirstExample:IFirstExample
{
publicstringName{get;set;}=string.Empty;
publicintCount{get;set;}
publicboolIsActive{get;set;}
}
/// <summary>
/// Interface used by the first example class.
/// </summary>
publicinterfaceIFirstExample
{
stringName{get;set;}
intCount{get;set;}
boolIsActive{get;set;}
}
/// <summary>
/// Second example class containing a property typed to the interface.
/// </summary>
publicclassSecondExample
{
publicIFirstExampleFirst{get;set;}
publicdoubleValue{get;set;}
publicDateTimeTimestamp{get;set;}
publicSecondExample(IFirstExample first)
{
First= first;
Value=0.0;
Timestamp=DateTime.UtcNow;
}
}
/// <summary>
/// Third example inherits from SecondExample and hides the interface-typed property
/// with a concrete implementation using the `new` keyword. This class is generic
/// over the interface type so different implementations of <see cref="IFirstExample"/>
/// can be used.
/// </summary>
/// <typeparam name="T">Type implementing <see cref="IFirstExample"/>.</typeparam>
publicclassThirdExample<T>:SecondExamplewhere T :IFirstExample
{
// Hides SecondExample.First (IFirstExample) with a concrete implementation of T.
publicnew T First{get;set;}
publicThirdExample(T first):base(first)
{
First= first;
}
}
--------------------------------------------
// Create a sample ThirdExample using the FirstExample implementation
// and show it in the Syncfusion PropertyGrid.
var sample =newThirdExample<FirstExample>(
newFirstExample
{
Name="Sample",
Count=3,
IsActive=true
}
);
// Assign to the PropertyGrid will cause exception System.Reflection.AmbiguousMatchException
propertyGrid.SelectedObject = sample;
Attachment: ExampleSyncPropertyGrid_f968d689.zip
Hi UserAaaaaad,
The System.Reflection.AmbiguousMatchException occurs because the PropertyGrid inspects your object using reflection. When a derived class declares a property with the same name as one in the base class using the new keyword, both properties still exist in the type metadata. Reflection finds two members named First and cannot decide which one to use, which causes the exception.
The new keyword only changes compile‑time resolution in C#; it does not hide or remove the base property from reflection. Attributes like [Browsable(false)] are applied later during UI filtering, but the crash happens earlier when the grid first enumerates properties.
To resolve this, we renamed the derived property to ConcreteFirst and applied [DisplayName("First")] so the PropertyGrid still shows it as “First” to the user. This ensures:
Reflection sees only one property name, avoiding ambiguity.
The grid displays the property with the expected label.
Nested properties expand correctly in NestedMode.
We have attached the updated sample project with this fix applied. Please check it, and if you need any corrections or further adjustments, feel free to let us know — we’ll be glad to refine it further.
Regards,
Aravindhan Periyasamy
Attachment: PropertyGridWPFAmbigious_68a7f85f.zip
Hello,
thanks for you answer. I'm aware that changing the property in the classes would solve the issue.
I was looking for a solution without changing the classes. From your answer, this seems not possible at the moment.
I assume the property grid is calling this function, which causes the exception:
PropertyInfo property = type.GetProperty("name");
Would it be an option to improve this by calling GetProperties and only use the "highest" property by FirstOrDefault
PropertyInfo property = type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static).FirstOrDefault(p => p.Name == "name");
I guess this would require and update of the syncfusion function but would support more use cases?
Thanks in advance
Hi UserAaaaaad,
We have confirmed the reported scenario is a defect and logged a report for the reported scenario, “PropertyGrid throws AmbiguousMatchException when class hides base property with new keyword” We will fix this issue and include it in our NuGet release, which is scheduled for 24th March 2026.
You can track the status of this defect using the following feedback link: PropertyGrid throws AmbiguousMatchException when class hides base property with new keyword in WPF | Feedback Portal
Note: The provided feedback link is private, and you need to log in to view this feedback.
Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including, but not limited to, QA checks and work reprioritization.”
Regards,
Aravindhan Periyasamy
Hi UserAaaaaad,
We were unable to include the fix for the issue "PropertyGrid throws AmbiguousMatchException when class hides base property with new keyword" as promised in the weekly release scheduled to be published (24/03/2026). This fix will be included in the next weekly release (31/03/2026).
We apologize for any inconvenience this may have caused and appreciate your understanding.
Regards,
Aravindhan Periyasamy
Hi UserAaaaaad,
Root Cause: The AmbiguousMatchException occurs because the type defines more than one property with the same name.
We have included the fix for the reported issue “PropertyGrid throws AmbiguousMatchException when class hides base property with new keyword” in our Weekly NuGet release version 33.1.46 which is available for download (https://www.nuget.org/).
We thank you for your support and appreciate your patience in waiting for this update. Please get in touch with us if you require any further assistance.
Regards,
Aravindhan Periyasamy
- 5 Replies
- 2 Participants
-
US UserAaaaaad
- Mar 1, 2026 03:14 PM UTC
- Mar 31, 2026 09:34 AM UTC