如果在屏幕中禁用了按钮,则无法获取WPF切换按钮的Pressed属性 - CodedUI [英] Couldn't get the Pressed property of a WPF Toggle Button if the button is disabled in screen - CodedUI

查看:68
本文介绍了如果在屏幕中禁用了按钮,则无法获取WPF切换按钮的Pressed属性 - CodedUI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有很少的切换按钮,并选择切换按钮我使用下面的CodedUI代码,工作正常。 


BuyToggleButton.Pressed = true;


在某些地方,我想验证是否选择了ToggleButton,我有 下面的代码检查


if(BuyToggleButton.Pressed)


{


Console.Write(" ;按钮选择");


}


如果在屏幕中启用了切换按钮以进行编辑,则上面的代码正常工作,并且相同禁用切换按钮时,代码不起作用(Enabled属性设置为'False')。 


当我将十字准线放在启用控件上时,我得到Pressed属性,如果我将十字准线放在禁用的控件上我无法获得按下的属性。 


是否有任何方法可以确定在禁用切换按钮时是否按下切换按钮? / p>


谢谢,


迷你


解决方案

Hi minij007,


感谢您在MSDN论坛上发帖。


>>是否有任何方法可以确定在禁用切换按钮时是否按下切换按钮?


根据我的理解,我们无法在禁用时按下切换按钮,那么,为什么要在状态为
禁用时检查它?


通常,我们可以使用编码的UI测试来验证控制状态是启用还是禁用。


bool buttonstate = BuyToggleButton.Enabled;


Assert.IsFalse(buttonstate,
" Button is未启用" );



问候,


Judyzh

I have few toggle button in my application and to select a Toggle button I use the below CodedUI code which works fine. 

BuyToggleButton.Pressed = true;

In Some places I want to validate whether the ToggleButton is selected or not, and I have the  below code to check that

if (BuyToggleButton.Pressed)

{

Console.Write("Button Selected");

}

The above piece of Code works fine if the Toggle button is enabled for editing in screen, and the same code doesn't work when the Toggle button is disabled ( Enabled property set to 'False'). 

When I place the crosshair on the Enabled control I get the Pressed property, If I place the crosshair on the disabled control I couldn't get the Pressed Property. 

Is there any way to find whether the Toggle button is pressed or not when it is disabled?

Thanks,

Mini

解决方案

Hi minij007,

Thank you posting in MSDN forum.

>> Is there any way to find whether the Toggle button is pressed or not when it is disabled?

Based on my understanding, we can’t press the toggle button while it is disabled, so, why did you want to check it when it state is disabled?

Usually, we could use coded UI test to verify the control status is enabled or disabled.

bool buttonstate = BuyToggleButton.Enabled;

Assert.IsFalse(buttonstate, "Button is not enabled");

Regards,

Judyzh


这篇关于如果在屏幕中禁用了按钮,则无法获取WPF切换按钮的Pressed属性 - CodedUI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆