private object CreateFromString(Type targetType,string name)
{
object instance = null;
if (FrameworkElement != null)
{
instance = FrameworkElement.FindResource(name);
if (instance != null && targetType.IsAssignableFrom(instance.GetType())) return instance;
instance = null;
}
if(Contains(name))
{
instance = this[name];
if (instance != null && targetType.IsAssignableFrom(instance.GetType())) return instance;
instance = null;
}
if (!RequireExactMatch)
{
foreach (string key in Keys)
{
if (key.Contains(name))
{
instance = this[key];
if (instance != null && targetType.IsAssignableFrom(instance.GetType())) return instance;
}
}
}
return null;
}