title | description | ms.date |
---|---|---|
Breaking change: 'GetXmlNamespaceMaps' type change |
Learn about the breaking change in .NET 9 for WPF where the backing property of 'XmlNamespaceMaps' has been changed from 'String' to 'Hashtable'. |
03/15/2024 |
The backing property of xref:System.Windows.Markup.XmlAttributeProperties.XmlNamespaceMaps?displayProperty=nameWithType has been changed from xref:System.String to xref:System.Collections.Hashtable.
.NET 9 Preview 3
Previously, the backing property of xref:System.Windows.Markup.XmlAttributeProperties.XmlNamespaceMaps was xref:System.String. However, the value returned by dependencyObject.GetValue(XmlNamespaceMapsProperty)
is of type xref:System.Collections.Hashtable and the xref:System.Windows.Markup.XmlAttributeProperties.GetXmlNamespaceMaps(System.Windows.DependencyObject) implementation tried to type cast it to xref:System.String, which resulted in an xref:System.InvalidCastException.
In addition, the xref:System.Windows.Markup.XmlAttributeProperties.SetXmlNamespaceMaps(System.Windows.DependencyObject,System.String) method accepted a xref:System.String argument.
Starting in .NET 9, the backing property of xref:System.Windows.Markup.XmlAttributeProperties.XmlNamespaceMaps is xref:System.Collections.Hashtable, and the xref:System.InvalidCastException is no longer thrown by xref:System.Windows.Markup.XmlAttributeProperties.GetXmlNamespaceMaps(System.Windows.DependencyObject).
In addition, the xref:System.Windows.Markup.XmlAttributeProperties.SetXmlNamespaceMaps(System.Windows.DependencyObject,System.Collections.Hashtable) method now accepts a xref:System.Collections.Hashtable argument.
This change is a behavioral change and can also affect source compatibility.
This change was made to prevent the xref:System.InvalidCastException from being thrown.
Pass Hashtable
instead of a string to the xref:System.Windows.Markup.XmlAttributeProperties.SetXmlNamespaceMaps%2A API.
- xref:System.Windows.Markup.XmlAttributeProperties.GetXmlNamespaceMaps(System.Windows.DependencyObject)?displayProperty=fullName
- xref:System.Windows.Markup.XmlAttributeProperties.SetXmlNamespaceMaps%2A?displayProperty=fullName