private async void Session_Save(object sender, RoutedEventArgs e)
        {
            SwagDataSet.Display = SessionName;
            SwagItemPreOrderIterator <SwagData> itrSwagData = SwagDataSet.CreateIterator();

            SwagWindow.GlobalIsBusy = true;

            await Task.Run(() =>
            {
                for (SwagData sd = itrSwagData.First(); !itrSwagData.IsDone; sd = itrSwagData.Next())
                {
                    if (sd is SwagDataTable sdt && !sdt.IsInitialized)
                    {
                        SwagDataGrid.InitSwagDataTable(sdt);
                    }
                }
            });

            SwagDataSet sdsSession = SwagWPFContainer.SwagDataService.SwagDataSets.Where(sds => sds.Display == SessionName).FirstOrDefault();

            if (sdsSession == SwagDataSet)
            {
                SwagWPFContainer.SwagDataService.SwagDataSets.Update(SwagDataSet);
            }
            else
            {
                SwagWPFContainer.SwagDataService.SwagDataSets.Add(SwagDataSet);
            }
            SwagWindow.GlobalIsBusy = false;
            SwagWPFContainer.SwagDataService.Save();
        }
        private async void Session_Load(object sender, RoutedEventArgs e)
        {
            SwagDataSet sdsSession = null;

            SwagWindow.GlobalIsBusy = true;
            await Task.Run(() =>
            {
                sdsSession = SwagWPFContainer.SwagDataService.SwagDataSets.Where(sds => sds.Display == SessionName).FirstOrDefault();
            });

            if (sdsSession != null)
            {
                SwagWPFContainer.SwagDataService.Init(sdsSession);
                SwagDataSet = sdsSession;
                SwagItemPreOrderIterator <SwagData> itrSwagData = SwagDataSet.CreateIterator();
                for (SwagData sd = itrSwagData.First(); !itrSwagData.IsDone; sd = itrSwagData.Next())
                {
                    if (sd is SwagDataTable sdt)
                    {
                        if (!sdt.IsInitialized)
                        {
                            SwagDataGrid.InitSwagDataTable(sdt);
                        }
                        sdt.FilterCommand.Execute(null);
                    }
                }
            }
            SwagWindow.GlobalIsBusy = false;
        }
        private async void Search_OnSearch(object sender, RoutedEventArgs e)
        {
            SearchTextBox searchTextBox = (SearchTextBox)sender;
            SwagData      swagData      = (SwagData)((SwagTabItem)searchTextBox.DataContext).ViewModel;
            SwagItemPreOrderIterator <SwagData> itrSwagData = SwagDataSet.CreateIterator();

            SwagWindow.GlobalIsBusy = true;
            await Task.Run(() =>
            {
                for (SwagData sd = itrSwagData.First(); !itrSwagData.IsDone; sd = itrSwagData.Next())
                {
                    if (sd is SwagDataTable sdg && !sdg.IsInitialized)
                    {
                        SwagDataGrid.InitSwagDataTable(sdg);
                    }
                }
            });

            SwagWindow.GlobalIsBusy = false;

            SwagDataResult swagDataResult = SwagDataSet.Search(searchTextBox.Text, searchTextBox.FilterMode,
                                                               (sdc, sdr, searchValue, filterMode) =>
            {
                String compareTarget = sdr.DataRow[sdc.ColumnName].ToString();
                String compareValue  = searchValue;
                return(SearchHelper.Evaluate(compareTarget, compareValue, false, filterMode, false));
            });

            swagData.SwagDataResult = swagDataResult;
        }
        private static void BindableSelectedColumnPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            SwagDataGrid fdgDataGrid = source as SwagDataGrid;

            if (e.NewValue != null)
            {
                fdgDataGrid.View((SwagDataColumn)e.NewValue);
            }
        }
        private static void SwagDataTablePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SwagDataGrid swagDataGrid = (SwagDataGrid)d;

            if (swagDataGrid != null && swagDataGrid.SwagDataTable != null && !swagDataGrid.SwagDataTable.IsInitialized)
            {
                SwagDataTable swagDataTable = swagDataGrid.SwagDataTable;
                InitSwagDataTable(swagDataTable);
            }
        }
        private static void BindableSelectedRowPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            SwagDataGrid fdgDataGrid = source as SwagDataGrid;

            if (e.NewValue != null)
            {
                SwagDataRowResult rowResult = (SwagDataRowResult)e.NewValue;
                fdgDataGrid.View(rowResult);
            }
        }
        private static void BindableColumnsPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            SwagDataGrid fdgDataGrid = source as SwagDataGrid;
            DataGrid     dataGrid    = fdgDataGrid.DataGrid;

            if (dataGrid != null)
            {
                dataGrid.Dispatcher.Invoke(new Action(() =>
                {
                    #region columnCollectionChanged
                    Action <object, NotifyCollectionChangedEventArgs> columnCollectionChanged = (s, ne) =>
                    {
                    };
                    #endregion columnCollectionChanged

                    if (e.NewValue != null)
                    {
                        ICollectionView columns         = UIHelper.GetCollectionView((IEnumerable)e.NewValue);
                        SortDescription sortDescription = new SortDescription("Value.ColSeq", ListSortDirection.Ascending);
                        if (!columns.SortDescriptions.Contains(sortDescription))
                        {
                            columns.SortDescriptions.Add(sortDescription);
                        }
                        columns.Filter = (itm) =>
                        {
                            KeyValuePair <String, SwagDataColumn> kvp = (KeyValuePair <String, SwagDataColumn>)itm;
                            return(kvp.Value.IsVisible);
                        };

                        dataGrid.Columns.Clear();
                        foreach (KeyValuePair <String, SwagDataColumn> sdcKvp in columns)
                        {
                            dataGrid.Columns.Add(sdcKvp.Value.DataGridColumn());
                            sdcKvp.Value.Init();
                        }

                        columns.CollectionChanged += fdgDataGrid.Columns_CollectionChanged;
                    }

                    if (e.OldValue is IEnumerable oldCol)
                    {
                        ICollectionView columns    = UIHelper.GetCollectionView(oldCol);
                        columns.CollectionChanged -= fdgDataGrid.Columns_CollectionChanged;
                    }
                }));
            }
        }