2016-08-21 227 views
1
private void newmail_Click(object sender, RoutedEventArgs e) 
    { 
     Nieuweemail _nieuweEmail = new Nieuweemail(_username); 
     _nieuweEmail.Show(); 
    } 

當該窗口關閉時,我想調用一個函數在我的主窗口中執行。Wpf檢測何時從不同的窗口關閉窗口

 _nieuweEmail.Closed += setContent(); 

我可以這樣做,如果我可以在將要關閉的窗口中調用它。但事實並非如此。我如何檢測這個?

+0

有什麼不想要調用'setContent()的原因;'在關閉窗口? – DNKROZ

+0

它不工作,哈哈:) – user3117628

回答

1

假設setContentnewmail_Click是你的主窗口兩種方法...

private void newmail_Click(object sender, RoutedEventArgs e) 
{ 
    Nieuweemail _nieuweEmail = new Nieuweemail(_username); 
    _nieuweEmail.Closed += SetContentHandler; 
    _nieuweEmail.Show(); 
} 

private void SetContentHandler(object sender, EventArgs e) 
{ 
    setContent(); 
} 
+0

不能隱式轉換類型無效的System.eventhandler – user3117628

+0

@ user3227070我認爲你需要改變'_nieuweEmail.Closed + = setContent();'爲'_nieuweEmail.Closed + = setContent;' – Xerillio

+0

沒有超載的setContent匹配委託Eventhandler – user3117628