关注Excel VSTO WPF应用程序

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

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

但是他们都没有工作。

好吧,我find了一个somesort的解决scheme:在closures,我用一个事件处理程序将其设置为隐藏的可见性:

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

为了处理最小化的WPF应用程序的焦点,我将windowstate设置为Normal:

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

这似乎工作正常。