void windowCommand(object obj)
        {
            StudentView view = obj as StudentView;

            _dg   = view.dg;
            _view = view;

            this.loadDataGrid();

            this.RefreshStudentPreselections();

            _dg.ItemsSource = this.Students;
        }
Beispiel #2
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.main = ((OSKernel.Presentation.Arranging.Mixed.Modify.Views.StudentView)(target));
                return;

            case 2:
                this.dg = ((System.Windows.Controls.DataGrid)(target));
                return;
            }
            this._contentLoaded = true;
        }
        void windowCommand(object obj)
        {
            StudentView view = obj as StudentView;

            _dg   = view.dg;
            _view = view;

            if (_dg != null)
            {
                if (_dg.Columns.Count > 3)
                {
                    var number = _dg.Columns.Count;

                    for (int i = number; i > 3; i--)
                    {
                        _dg.Columns.Remove(_dg.Columns[i - 1]);
                    }
                }

                var cl = CommonDataManager.GetCLCase(base.LocalID);

                cl.Courses.ForEach(c =>
                {
                    DataGridTextColumn dgtc = new DataGridTextColumn();
                    dgtc.Header             = c.Name;
                    dgtc.Binding            = new Binding($"ExpandoObject.{c.Name}");

                    //DataTemplate dt = new DataTemplate();
                    //FrameworkElementFactory factory = new FrameworkElementFactory(typeof(Label));
                    //factory.SetValue(Label.TagProperty, c.Name);
                    //factory.AddHandler(Label.LoadedEvent, new RoutedEventHandler(courseTextBlockLoaded));
                    //dt.VisualTree = factory;

                    //dgtc.CellTemplate = dt;

                    GalaSoft.MvvmLight.Threading.DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        _dg.Columns.Add(dgtc);
                    });
                });

                this.RefreshStudentPreselections();

                _dg.ItemsSource = this.Students;
            }
        }