示例#1
0
        public CustomColumnChooser(SfDataGrid dataGrid, CustomColumnChooserViewModel viewModel, ObservableCollection <ColumnChooserItems> totalColumns)
        {
            this.DefaultStyleKey = typeof(CustomColumnChooser);
            this.DataContext     = viewModel;
            this.dataGrid        = dataGrid;
            var res = new DataGrid.ColumnChooserDemo();

            this.Style = res.Resources["customstyle"] as Style;
        }
 /// <summary>
 /// Shows the ColumnChosser
 /// </summary>
 void ShowColumnChooser()
 {
     if (viewModel.ShowColumnChooser && viewModel.UseDefaultColumnChooser)
     {
         chooserWindow.Popup.HorizontalOffset = (this.sfGrid.ActualWidth) / 2 + (200);
         chooserWindow.Popup.VerticalOffset   = (this.sfGrid.ActualHeight) / 2 - (100);
         chooserWindow.Popup.IsOpen           = true;
         viewModel.CustomChooser.IsOpen       = false;
     }
     else if (viewModel.ShowColumnChooser && viewModel.UseCustomColumnChooser)
     {
         var visibleColumns = this.sfGrid.Columns;
         ObservableCollection <ColumnChooserItems> totalColumns = GetColumnsDetails(visibleColumns);
         CustomColumnChooserViewModel chooserViewModel          = new CustomColumnChooserViewModel(totalColumns);
         CustomColumnChooser          ColumnChooserView         = new CustomColumnChooser(this.sfGrid, chooserViewModel, totalColumns);
         viewModel.CustomChooser.Child            = ColumnChooserView;
         chooserWindow.Popup.IsOpen               = false;
         viewModel.CustomChooser.HorizontalOffset = (this.sfGrid.ActualWidth / 2) - (75) + (200);
         viewModel.CustomChooser.VerticalOffset   = (this.sfGrid.ActualHeight / 2) - (75) - (100);
         viewModel.CustomChooser.IsOpen           = true;
         viewModel.CustomChooser.Closed          += OnCustomChooser_Closed;
     }
 }