[英]Focus on Excel VSTO WPF application
I'm hosting WPF application within an Excel VSTO Add-in and it works fine onload, however after minimizing the WPF dialog, can't seem to get it to activate (focus) again using code. 我在Excel VSTO加载项中托管WPF应用程序并且它可以正常工作,但是在最小化WPF对话框之后,似乎无法使用代码再次激活(聚焦)它。 Have tried:
试过:
this.Show();
this.Activate();
this.BringIntoView();
this.Focus();
But none of them work. 但它们都不起作用。
Ok, I found a solution of somesort: On Close, I used an event handler to set it the visiblity to Hidden: 好吧,我找到了somesort的解决方案:在Close上,我使用了一个事件处理程序将它设置为隐藏的可见性:
private void ClientOnClosing(object sender, CancelEventArgs cancelEventArgs)
{
cancelEventArgs.Cancel = true;
_client.Visibility = Visibility.Hidden;
}
To handle focus a minimized WPF application, I set the windowstate to Normal: 为了处理焦点最小化的WPF应用程序,我将windowstate设置为Normal:
public void ShowDialog()
{
if (this.WindowState == WindowState.Minimized)
this.WindowState = WindowState.Normal;
this.Show();
}
This seems to work ok. 这似乎工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.