单击WPF后更改按钮的效果

时间:2017-09-18 12:06:41

标签: c# wpf xaml

我想在按下[RemoteTestNG] detected TestNG version 6.12.0 launching Chrome browser pass Starting ChromeDriver 2.16.333243 (0bfa1d3575fc1044244f21ddb82bf870944ef961) on port 44253 Only local connections are allowed. FAILED CONFIGURATION: @BeforeClass beforeClass org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: host: '01HW743357', ip: '10.145.128.186', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_101' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:646) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:255) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:237) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:138) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:178) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:167) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124) at PLM.NewTest.beforeClass(NewTest.java:21) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108) at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146) at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:165) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105) at org.testng.TestRunner.privateRun(TestRunner.java:776) at org.testng.TestRunner.run(TestRunner.java:634) at org.testng.SuiteRunner.runTest(SuiteRunner.java:425) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:420) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:385) at org.testng.SuiteRunner.run(SuiteRunner.java:334) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1318) at org.testng.TestNG.runSuitesLocally(TestNG.java:1243) at org.testng.TestNG.runSuites(TestNG.java:1161) at org.testng.TestNG.run(TestNG.java:1129) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77) Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137) at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153) at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:282) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163) at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:165) at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:139) at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:87) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:337) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) ... 33 more SKIPPED CONFIGURATION: @AfterClass afterClass SKIPPED: f org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: host: '01HW743357', ip: '10.145.128.186', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_101' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:646) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:255) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:237) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:138) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:178) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:167) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124) at PLM.NewTest.beforeClass(NewTest.java:21) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108) at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146) at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:165) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105) at org.testng.TestRunner.privateRun(TestRunner.java:776) at org.testng.TestRunner.run(TestRunner.java:634) at org.testng.SuiteRunner.runTest(SuiteRunner.java:425) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:420) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:385) at org.testng.SuiteRunner.run(SuiteRunner.java:334) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1318) at org.testng.TestNG.runSuitesLocally(TestNG.java:1243) at org.testng.TestNG.runSuites(TestNG.java:1161) at org.testng.TestNG.run(TestNG.java:1129) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77) Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137) at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153) at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:282) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163) at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:165) at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:139) at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:87) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:337) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) ... 33 more 时应用以下更改。

Button

1 个答案:

答案 0 :(得分:2)

如何处理Click的<{1}}事件?

Button
<Button Content="Click me!" Click="Button_Click_1" Margin="10" />

如果您只想在按下按钮时显示阴影,请使用绑定到private void Button_Click_1(object sender, RoutedEventArgs e) { Button button = sender as Button; button.Effect = new System.Windows.Media.Effects.DropShadowEffect() { BlurRadius = 10, ShadowDepth = 5 }; } 属性的Style

IsPressed

或使用<Button Content="Button"> <Button.Style> <Style TargetType="Button"> <Style.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter Property="Effect"> <Setter.Value> <DropShadowEffect BlurRadius="10" ShadowDepth="5"/> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> </Button.Style> </Button> 并根据ToggleButton属性设置Effect属性:

IsChecked