public void CloseFunction(ApplicationFunction function)
 {
     UserControlFunctionItem<ApplicationFunction> first =
     openedUserControlCollection.FirstOrDefault(f => f.Data.ID == function.ID);
       if (first != null)
       {
     //test if exist when the collection removed
     var dispose = first.Content as IDisposable;
     if (dispose != null)
       dispose.Dispose();
     openedUserControlCollection.Remove(first);
       }
 }
        public virtual void FunctionClick(ApplicationFunction function)
        {
            UserControlFunctionItem<ApplicationFunction> first =
            openedUserControlCollection.FirstOrDefault(f => f.Data.ID == function.ID);
              if (first != null)
              {
            CurrentUserControl = first;
            return;
              }
              var control = new UserControlFunctionItem<ApplicationFunction>(function.ImageUrl, CloseFunction)
              {
            Header = function.Name,
            Data = function,
            Content = GetContentFromFunction(function),
              };

              var showProgress = control.Content.DataContext as IProgress;
              if (showProgress != null)
              {
            showProgress.StartShowing = s => control.Progress.ShowProgress(string.Format("Loading {0}", function.Name));
            showProgress.StopShowing = () => control.Progress.HideProgress();
              }

              var dataLoad = control.Content as IDataLoad;
              if (dataLoad != null)
              {
            dataLoad.Load();
              }

              openedUserControlCollection.Add(control);
              CurrentUserControl = control;
              NotifyOfPropertyChange(() => OpenedUserControlCollection);
        }
 public abstract FrameworkElement GetContentFromFunction(ApplicationFunction function);