专注于Excel VSTO WPF应用程序 [英] Focus on Excel VSTO WPF application

查看:277
本文介绍了专注于Excel VSTO WPF应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个Excel VSTO加载项中托管WPF应用程序,它的工作正常,但是在最小化WPF对话框之后,似乎无法使用代码再次激活(重点)。
尝试过:

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

但没有一个工作。

解决方案

好的,我发现一个somesort的解决方案:
关闭,我使用一个事件处理程序将其设置为隐藏的可见性:

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

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

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

这似乎工作正常。


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. 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:

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:

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

This seems to work ok.

这篇关于专注于Excel VSTO WPF应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆