所以我创建了一个用户控件,并且我在它上面创建了一个依赖属性TestProperty。UWP XAML用户控件静态属性与实例属性
我希望有2个此用户控件的实例并为每个实例设置TestProperty为不同的值。
<widgets:mycontrol Test="val1"></widgets:WTComboBox>
<widgets:mycontrol Test="val2"></widgets:WTComboBox>
如果我创建testproperty为静态的DependencyProperty如下:
public static readonly DependencyProperty TestProperty=
DependencyProperty.Register("Test", typeof(string), typeof(mycontrol), null);
在控制
,那么显然我不能在每个实例的一个不同的值,但是当我创建testproperty作为一个正常的实例属性
public DependencyProperty TestProperty;
public mycontrol()
{
TestProperty = DependencyProperty.Register("Test", typeof(string), typeof(mycontrol), null);
}
上的控制,那么设计师不能识别属性存在,并创建一个错误,但在运行时控制完美的作品一nd控件的每个实例都具有测试属性的正确值。
所以问题是我如何获得实例dependencyproperty的工作在设计器?
感谢