2012-04-27 15 views
0

私のデフォルトのキーを押すと、ボタンが押されてリリースされたエフェクト(マウスの押下をシミュレートする)になります。デフォルトのキーが押されたときにボタンが押された効果を表示

私はこの

private void OnKeyDownHandler(object sender, KeyEventArgs e) 
     { 
      if (e.Key == Key.Enter) 
      { 
       VisualStateManager.GoToState(btnLogin, "Pressed", true); 
       System.Threading.Thread.Sleep(300); 
       VisualStateManager.GoToState(btnLogin, "Normal", true); 
       btnLogin_Click(sender, e); 

      } 
     } 

カントはそれが仕事を得ることを試みました。

答えて

0

はあなたのボタンプロパティのIsDefaultを作った=真

+0

はい私が使用した試しのIsDefault =私はこれを使用することを追加する必要が何をすべきか真 – deception1

0

次 は「

private void OnKeyDownHandler(object sender, KeyEventArgs e) 
    { 
     if (e.Key == Key.Enter) 
     { 
      VisualStateManager.GoToState(btnLogin, "Pressed", true); 
      this.Refresh(); 
      System.Threading.Thread.Sleep(300); 
      VisualStateManager.GoToState(btnLogin, "Normal", true); 
      this.Refresh(); 
      btnLogin_Click(sender, e); 
     } 
    } 

+0

WPFにRefresh()がありません – deception1

+0

ボタンの状態が変化していても、塗りつぶされません。リフレッシュは、Windowsフォームアプリケーション用の画面上のコントロールを描画するので、同じことがここのケースになると思います.... – kingpin

関連する問題