問題私が検出し、VSTOアドインを使用して、PowerPointで開かれたWPFのダイアログボックスを閉じますしようとしているMicrosoft PowerPoint/Officeアプリケーションでモーダルダイアログボックスを閉じる方法を教えてください。
。 this questionのソリューションを使用すると、ダイアログボックスが開いているのに、System.Windows.Application.Current
が常にnullイベントを返すため、動作していないようです。
コード
代わりにダイアログボックスとしてデフォルトのWinフォームを使用しての、私のダイアログボックスが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ウィンドウを開きます
using (DlgCustomWindow dlgCustom = new DlgCustomWindow())
{
dlgCustom.ShowDialog();
}
しかし、System.Windows.Application.Current
を実行すると常にnullが返されます。