2014-01-08 41 views
0

我在一个Excel VSTO外接程序中托管WPF应用程序,并且它可以正常工作,但是在最小化WPF对话框之后,似乎无法使用代码再次激活(焦点) 。 曾尝试:专注于Excel VSTO WPF应用程序

this.Show(); 
    this.Activate(); 
    this.BringIntoView(); 
    this.Focus(); 

但他们没有工作。

回答

2

好的,我发现somesort的溶液: 在关闭中,我使用的事件处理程序来设置它的可见为隐藏:

private void ClientOnClosing(object sender, CancelEventArgs cancelEventArgs) 
     { 
      cancelEventArgs.Cancel = true; 
      _client.Visibility = Visibility.Hidden; 
     } 

为了处理集中最小化的WPF应用程序,我将WindowState设置为正常:

public void ShowDialog() 
     { 
      if (this.WindowState == WindowState.Minimized) 
       this.WindowState = WindowState.Normal; 
      this.Show(); 
     } 

这似乎工作正常。