我准备了带有自定义控件(ButtonAdv)的简单示例(WindowsForms),该控件源自Microsoft Button控件。通过以下博客,我的自定义属性(BackColor和ForeColor等)实现了对该自定义控件的CodedUI扩展支持,
一切正常,在断言我的自定义控件时,在CodedUITestBuilder属性窗口中正确添加了自定义属性。
问题: 当我尝试断言Microsoft Button时,我的自定义属性(BackColor,ForeColor)在CodedUITestBuilder属性窗口中显示为空值。
我不知道为什么会这样。请有人建议我如何避免断言MicroSoft控件的自定义属性?
以下是我实施的最低限度代码,
public class SfButtonAdv1:WinControl
{
public SfButtonAdv1(UITestControl control)
: base(control)
{
SearchProperties.Add(UITestControl.PropertyNames.ControlType, ControlType.Button.Name);
}
new public abstract class PropertyNames : WinControl.PropertyNames
{
public static readonly string BackColor = "BackColor";
public static readonly string ForeColor = "ForeColor";
}
}
public class SfButtonAdv : Button
{
public SfButtonAdv()
{
}
protected override AccessibleObject CreateAccessibilityInstance()
{
return new SfButtonAccessiblity(this);
}
}
public class SfButtonAccessiblity : ControlAccessibleObject
{
//
public override string Description
{
get
{
return this.sfButtonAdv.Style.BackColor.Name
+ "," + this.sfButtonAdv.Style.ForeColor.Name
}
}
}
先谢谢,