IM在ShowDialog的是如何工作的在WPF卸載對話框
Im做這個
NewReportDialog nrDialog = new NewReportDialog();
nrDialog.DataContext = ServiceLocator.Current.GetInstance<INewReportViewModel>();
nrDialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
nrDialog.Owner = Application.Current.MainWindow;
bool? dialogResult = nrDialog.ShowDialog();
if (dialogResult.HasValue && dialogResult.Value)
{
Console.WriteLine(((INewReportViewModel)nrDialog.DataContext).ReportName);
Console.WriteLine(((INewReportViewModel)nrDialog.DataContext).SelectedSite);
}
令我百思不解的是,我仍然可以讀取的DataContext對話框關閉後,有點不確定。我如何確保對話框被卸載或者我必須依賴垃圾回收器
感謝這兩個,不知道我錯過了 – klashagelqvist 2012-01-27 17:13:00