我在Excel VSTO加载项中托管WPF应用程序并且它可以正常运行onload,但是在最小化WPF对话框后,似乎无法使用代码再次激活(焦点)。 试过了:
this.Show();
this.Activate();
this.BringIntoView();
this.Focus();
但它们都不起作用。
答案 0 :(得分:2)
好的,我找到了somesort的解决方案: 在Close上,我使用了一个事件处理程序将它设置为隐藏的可见性:
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();
}
这似乎没问题。