2014-03-07 2 views
1

상단의 메뉴 항목에 select, save, clear, exit 항목이있는 wpf 페이지가 있습니다. 메뉴 아래에는 공급 업체 코드를 받아들이는 텍스트 상자가 있습니다. 공급자 코드를 검증해야하는 텍스트 상자의 초점을 잃어 버렸고 사용자가 종료 메뉴 항목을 클릭하면이 유효성 검사가 발생하지 않아야합니다. 이 쉽게 Windows 응용 프로그램에서 탭 인덱스를 확인하여 얻을 수 있지만 WPF 페이지에서 우리는 어떻게 달성 해야할지 모르겠어. 코드는 우리가 wpf 페이지에서 필요한 windows application.same 기능에서 이루어집니다.Lost focus 이벤트의 유효성 확인

우리가 C#에서 코드가 필요

Private Sub txtSupp_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSupp.Leave 
    If Me.ActiveControl Is Nothing Then Exit Sub 
    If Me.ActiveControl.TabIndex <= txtSupp.TabIndex And _ 
    Me.ActiveControl.Parent.TabIndex <= txtSupp.Parent.TabIndex Then Exit Sub 
    Dim lsErrmsg As String 
    cowSIMaintain.Validate_Supp(Me, lsErrmsg) 
End Sub 
+0

답장을 보내 주셔서 감사하지만 wpf 페이지에서 구문이 작동하지 않습니다. Windows 응용 프로그램에서만 작동합니다. – user1892203

+0

죄송합니다. wpf 답변으로 답변을 업데이트했습니다. – safetyOtter

답변

0
private void txtSupp_LostFocus(object sender, RoutedEventArgs e) 
    { 
     var focusedControl = Keyboard.FocusedElement; 
     if (focusedControl.GetType() == typeof(Button)) 
     { 
      var but = focusedControl as Button; 
      if (but == null) 
      { 
       return; 
      } 
      if (but.Name == "ImTheExitButton") 
      { 
       return; 
      } 
     } 

     string lsErrmsg = null; 
     cowSIMaintain.Validate_Supp(this, lsErrmsg); 
    } 

미안 내가 매달려를 왼쪽 잊었 .. 당신이 유용 할 시간이 얻을 희망, 그것은 당신이 무엇을해야한다, 또는 적어도 점을에 올바른 방향.