After migrating a WPF class library to a UWP class library, the following code is throwing an error. The PropertyType property of DependencyProperty class worked in WPF. I tried to get help from Dependency properties overview of similar class in UWP and this online article but got a bit confused.
What I'm missing here and how can I make it work?
Code snippet [error occurs at first line of the method]:
using Windows.UI.Xaml;
using System.Reflection;
using Windows.UI.Xaml.Documents;
using System.ComponentModel;
....
private static void SetPropertyValue(XmlElement xamlElement, DependencyProperty property, string stringValue)
{
TypeConverter typeConverter TypeDescriptor.GetConverter(property.PropertyType);
try
{
object convertedValue = typeConverter.ConvertFromInvariantString(stringValue);
if (convertedValue != null)
{
xamlElement.SetAttribute(property.Name, stringValue);
}
}
catch(Exception)
{
}
}
Error:
'DependencyProperty' does not contain a definition for 'PropertyType' and no accessible extension method 'PropertyType' accepting a first argument of type 'DependencyProperty' could be found (are you missing a using directive or an assembly reference?)
Snapshot of "ALL" the packages installed: