/// <summary>
        /// Occures when selection changed on TabControl.
        /// If add-item is pressed create new tab-item otherwise do nothing.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TabControlDynamic_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TabItem item = TabControlDynamic.SelectedItem as TabItem;

            if (item == null)
            {
                AllTabsClosed?.Invoke();
                return;
            }

            if (_observableViewModel.IsAddTabItem(item))
            {
                _observableViewModel.AddTabItem(TabControlDynamic.FindResource("TabHeader") as DataTemplate);
            }
        }
        /// <summary>
        /// Init test page with a test model.
        /// </summary>
        /// <param name="testModel"></param>
        public void Edit(TestModel testModel)
        {
            IsInEditMode = true;
            _observableViewModel.SubjectName = testModel.Name;

            for (int i = 0; i < testModel.Questions.Count; ++i)
            {
                if (i == 0)
                {
                    _questionsDictionary.Add(i, testModel.Questions[i]);
                    WriteChangesToQuestionPage(i);
                    continue;
                }


                _observableViewModel.QuestionContainerContentRenderd +=
                    ObservableViewModelOnQuestionContainerContentRenderd;
                _observableViewModel.AddTabItem(TabControlDynamic.FindResource("TabHeader") as DataTemplate);
                _questionsDictionary.Add(i, testModel.Questions[i]);
            }
        }
 /// <summary>
 /// Occures when tabcontrol is loaded.
 /// Create first tab and "add-tab"
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TabControlDynamic_OnLoaded(object sender, RoutedEventArgs e)
 {
     _observableViewModel.InitTabControl(TabControlDynamic.FindResource("TabHeader") as DataTemplate);
 }