OnClick...
{
RadWindow RadWindow_tmp = new RadWindow ();
RadWindow_tmp.Show();
Object RadWindow_tmp_Content = new Object();
RadWindow_tmp_Content = new uc_Employee("test", 7);
RadWindow_tmp.Content = RadWindow_tmp_Content;
RadWindow_tmp_Content =null;//no need for these line
}
when i close the window
i make the following
i make ( before GC.Collect();)
RadWindow MainRadWindow = RadWindow.GetParentRadWindow(this);
(MainRadWindow.Content as uc_Employee).DataContext = null;
MainRadWindow.Content = null;
alos i call "GC" (alos i use a timer to call it)
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
I also use WeakReference to see is the control and the radwindow isAlive.
after i close the window the radwindow is not on the memory
but the control "uc_Employee" still on the memory
on these case after several time the user open new radwindow the application also the computer crash.
please i need some help how i can release the control from the memory.
Is these bug on silverlight4. how i can solve the till we get SL5.
best regards.
public
void
ShowPopup(
string
title, FrameworkElement content,
double
x,
double
y,
double
width,
double
height,
string
instanceName,
bool
isModal, EventHandler<WindowClosedEventArgs> closedEvent)
{
if
(isModal) { currentPopup = instanceName; }
PopupRadWindow popupWindow;
if
(popUpWindowDictionary.ContainsKey(instanceName))
{
popupWindow = popUpWindowDictionary[instanceName];
if
(popupWindow !=
null
)
{
popupWindow.Close();
popUpWindowDictionary.Remove(instanceName);
}
}
Visibility userAccessButtonVisibility = Visibility.Collapsed;
string
moduleName =
string
.Empty;
bool
enblePermissionEdit =
bool
.Parse(ServiceProvider.Instance.InitParameters[ParameterNames.EnablePermissionEdit]);
if
(content
is
PopupModuleContent)
{
PopupModuleContent pc = content
as
PopupModuleContent;
if
(USER_ACCESS_VIEW_NAME != pc.ModuleName && enblePermissionEdit)
{
userAccessButtonVisibility = Visibility.Visible;
moduleName = pc.ModuleName;
AddParameter(ParameterNames.SilverlightModuleName, moduleName);
}
}
else
if
(USER_ACCESS_VIEW_NAME != GetModuleName(content) && enblePermissionEdit)
{
userAccessButtonVisibility = Visibility.Visible;
moduleName = GetModuleName(content);
AddParameter(ParameterNames.SilverlightModuleName, moduleName);
}
if
(RegionManager.Regions[RegionNames.MainRegion] !=
null
|| RegionManager.Regions[RegionNames.MainRegion].ActiveViews.FirstOrDefault() !=
null
)
{
ViewBase vb = RegionManager.Regions[RegionNames.MainRegion].ActiveViews.FirstOrDefault()
as
ViewBase;
if
(vb !=
null
)
AddParameter(ParameterNames.CurrentPageName, vb.PageName);
}
popupWindow =
new
PopupRadWindow(userAccessButtonVisibility);
if
(closedEvent !=
null
)
{
popupWindow.Closed += closedEvent;
}
if
(content
is
PopupModuleContent)
{
PopupModuleContent popupModuleContent = (PopupModuleContent)content;
if
(popupModuleContent.ContentControl !=
null
&&
popupModuleContent.ContentControl.Content
is
IPopupContent)
{
IPopupContent iPopupContent = (IPopupContent)popupModuleContent.ContentControl.Content;
iPopupContent.OKButtonClicked +=
delegate
{ popupWindow.DialogResult =
true
;popupWindow.Close(); };
iPopupContent.CancelButtonClicked +=
delegate
{ popupWindow.DialogResult =
false
; popupWindow.Close(); };
}
}
popupWindow.IsShowModal = isModal;
popUpWindowDictionary.Add(instanceName, popupWindow);
if
(content
is
PopupModuleContent)
{
popupWindow.ModuleName = moduleName;
}
popupWindow.Show(title, content, x, y, width, height);
}