내 아이 창을 닫을 때 언로드되도록하려면 어떻게해야합니까?닫을 때 childwindow 언로드
내 viewmodel에서 childwindow를 여는 중이지만 닫힌 후에도 combobox에서 selectionchanged와 같은 이벤트가 계속 발생합니다.
childwindow는 호출 된 것과 동일한 viewmodel을 사용하고 있으므로 이벤트가 시작되는 이유를 추측 할 수 있습니다. 아이템 소스는 여전히 유효합니다.
하지만 닫히면 아이 윈도우를 "처분"하고 싶습니다.
는그래서 내가 지금하고 있어요에서 itemssource을 제거하는 것입니다 ..
private void OnLaunchEditItem(ItemMessage msg)
{
var editWnd = new EditItemWindow();
editWnd.Closed += new EventHandler(editWnd_Closed);
editWnd.Show();
}
void editWnd_Closed(object sender, EventArgs e)
{
sender = null;
}
없음 sucesss :
나는 (뒤에 기본보기 코드)이 같은 폐쇄 형 처리기를 추가하려고했습니다 childwindow 컨트롤, 나에게 보인다 ... 문제에 대한 이상적인 해결책이 아닙니다. 닫을 때 메모리에서 모두 처분 할 수 있어야합니까? (Childwindow "보기"코드 숨김) 뷰 사이
private void OKButton_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
combobox1.ItemsSource = null;
combobox2.ItemsSource = null;
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
combobox1.ItemsSource = null;
combobox2.ItemsSource = null;
}
http://stackoverflow.com/questions/7036873/when-to-dispose-viewmodel-in-mvvm-light – Kman