问题如何触发模式对话框在Microsoft PowerPoint/Office应用程序中关闭?
我试图检测并关闭使用VSTO插件在PowerPoint中打开的WPF对话框。当我使用this question的解决方案时,似乎无法正常工作,因为System.Windows.Application.Current
总是会返回null事件,即使打开了一个对话框。
代码
不使用默认的Winform为对话框,我的对话框是一个WPF窗口,例如,
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
x:Name="Test"
WindowStyle="None"
SizeToContent="WidthAndHeight">
...
</Window>
这是后台代码:
namespace AddInProject.Classes
{
public partial class DlgCustomWindow:Window, IDisposable
{
public CustomWindow()
{
InitializeComponent();
}
public Dispose()
{
this.Close();
}
}
}
我使用此方法打开上述
WPF窗口但运行System.Windows.Application.Current
总是返回null。