有朋友遇到這樣的一個問題
問題的關鍵在於不能再Closing方法中調用Close等
假設我們的Window類型的win
我們實現一個Delegate
delegate void WillHide();
//
private WillHide willHide;
//
this
//
private void HideWin
{
this
}
當Closing時我們這樣
void win
{
e
Dispatcher
}Everything is OK!
整體的代碼
Code
using System;
using System
using System
using System
using System
using System
using System
using System
using System
using System
using System
using System
using System
using System
namespace ClosingDemo
{
/**//// <summary>
/// Interaction logic for Window
/// </summary>
public partial class Window
{
delegate void WillHide();
private Window
private WillHide willHide;
public Window
{
InitializeComponent();
Test();
}
private void HideWin
{
this
}
private void Test()
{
App
App
this
this
this
this
}
void btnShowWin
{
this
}
void win
{
e
Dispatcher
}
}
}
From:http://tw.wingwit.com/Article/program/ASP/201311/21706.html