您好我尝试创建Type
类型的附加属性,如下所示:
public static Type GetTargetType(DependencyObject obj)
{
return (Type)obj.GetValue(TargetTypeProperty);
}
public static void SetTargetType(DependencyObject obj, Type value)
{
obj.SetValue(TargetTypeProperty, value);
}
public static readonly DependencyProperty TargetTypeProperty =
DependencyProperty.RegisterAttached("TargetType", typeof(Type), typeof(MyHelper), new PropertyMetadata(null, OnTargetPropertyChanged));
private static void OnTargetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
// and here i want to use this type.
}
并在XAML代码中:
// ...
<myControl MyHelpeers:MyHelper.TargetType="{x:Type local:myclass}"/>
//...
我用Google搜索了这个我找到了一种创建类型表单字符串的方法。但我不喜欢这样。 请帮我。 感谢。