void BindGrid()
        {
            // create PagedCollectionView used as a data source for the
            // FlexGrid and for the MS DataGrid
            var data = new ObservableCollection <Customer>();

            for (int i = 0; i < ROW_COUNT; i++)
            {
                data.Add(new Customer(i));
            }
            var view = new MyCollectionView(data);

            using (view.DeferRefresh())
            {
                view.GroupDescriptions.Clear();
                view.GroupDescriptions.Add(new PropertyGroupDescription("Country"));
                view.GroupDescriptions.Add(new PropertyGroupDescription("Active"));
                var gd = view.GroupDescriptions[0] as PropertyGroupDescription;
                gd.Converter = new CountryInitialConverter();
            }

            // bind grids to ListCollectionView
            _flexGroup.ItemsSource = view;
            _flexGroup.KeyDown    += _flexGroup_KeyDown;
        }
예제 #2
0
        void BindITunesGrid()
        {
            var songs = MediaLibrary.Load();
            var view = new MyCollectionView(songs);
            using (view.DeferRefresh())
            {
                view.GroupDescriptions.Clear();
                view.GroupDescriptions.Add(new PropertyGroupDescription("Artist"));
                view.GroupDescriptions.Add(new PropertyGroupDescription("Album"));
            }
            var fg = _flexiTunes;
            fg.CellFactory = new MusicCellFactory();
            fg.MergeManager = null; // << review this, should not merge cells with content
            fg.Columns["Duration"].ValueConverter = new SongDurationConverter();
            fg.Columns["Size"].ValueConverter = new SongSizeConverter();
            fg.ItemsSource = view;

            // configure search box
            _srchTunes.View = view;
            foreach (string name in "Artist|Album|Name".Split('|'))
            {
                _srchTunes.FilterProperties.Add(typeof(Song).GetProperty(name));
            }

            // show media library summary (using Linq)
            view.CollectionChanged += songs_CollectionChanged;
            UpdateSongStatus();
        }
        public MouseHover()
        {
            InitializeComponent();
            Tag = FlexGridSamples.Properties.Resources.MouseHoverDescription;

            var data = new ObservableCollection <Customer>();

            for (int i = 0; i < ROW_COUNT; i++)
            {
                data.Add(new Customer(i));
            }
            var view = new MyCollectionView(data);

            using (view.DeferRefresh())
            {
                view.GroupDescriptions.Clear();
                view.GroupDescriptions.Add(new PropertyGroupDescription("Country"));
                view.GroupDescriptions.Add(new PropertyGroupDescription("Active"));
                var gd = view.GroupDescriptions[0] as PropertyGroupDescription;
                gd.Converter = new CountryInitialConverter();
            }

            // bind grids to ListCollectionView
            grid.ItemsSource = view;
        }
예제 #4
0
        void BindITunesGrid()
        {
            var songs = MediaLibrary.Load();
            var view  = new MyCollectionView(songs);

            using (view.DeferRefresh())
            {
                view.GroupDescriptions.Clear();
                view.GroupDescriptions.Add(new PropertyGroupDescription("Artist"));
                view.GroupDescriptions.Add(new PropertyGroupDescription("Album"));
            }
            var fg = _flexiTunes;

            fg.CellFactory  = new MusicCellFactory();
            fg.MergeManager = null; // << review this, should not merge cells with content
            fg.Columns["Duration"].ValueConverter = new SongDurationConverter();
            fg.Columns["Size"].ValueConverter     = new SongSizeConverter();
            fg.ItemsSource = view;

            // configure search box
            _srchTunes.View = view;
            foreach (string name in "Artist|Album|Name".Split('|'))
            {
                _srchTunes.FilterProperties.Add(typeof(Song).GetProperty(name));
            }

            // show media library summary (using Linq)
            view.CollectionChanged += songs_CollectionChanged;
            UpdateSongStatus();
        }
예제 #5
0
        public FullTextFilter()
        {
            InitializeComponent();

            var data = new ObservableCollection <Customer>();

            for (int i = 0; i < ROW_COUNT; i++)
            {
                data.Add(new Customer(i));
            }
            var view = new MyCollectionView(data);

            // bind grids to ListCollectionView
            grid.ItemsSource = view;

            grid.MinColumnWidth = 85;
        }
예제 #6
0
        void PopulateFinancialGrid()
        {
            _financialData = FinancialData.GetFinancialData();
            var view = new MyCollectionView(_financialData);
            _flexFinancial.ItemsSource = view;
            _flexFinancial.Columns.Frozen = 1;
            _flexFinancial.Columns[0].AllowDragging = false;

            // configure search box
            _srchCompanies.View = view;
            var props = _srchCompanies.FilterProperties;
            props.Add(typeof(FinancialData).GetProperty("Name"));
            props.Add(typeof(FinancialData).GetProperty("Symbol"));

            // show company info
            UpdateCompanyStatus();
            view.CollectionChanged += financial_CollectionChanged;

            UpdateCellFactory();
        }
예제 #7
0
        void BindGrid()
        {
            // create PagedCollectionView used as a data source for the
            // FlexGrid and for the MS DataGrid
            var data = new ObservableCollection<Customer>();
            for (int i = 0; i < ROW_COUNT; i++)
            {
                data.Add(new Customer(i));
            }
            var view = new MyCollectionView(data);
            using (view.DeferRefresh())
            {
                view.GroupDescriptions.Clear();
                view.GroupDescriptions.Add(new PropertyGroupDescription("Country"));
                view.GroupDescriptions.Add(new PropertyGroupDescription("Active"));
                var gd = view.GroupDescriptions[0] as PropertyGroupDescription;
                gd.Converter = new CountryInitialConverter();
            }

            // bind grids to ListCollectionView
            _flexSelectionMode.ItemsSource = view;
        }
        void PopulateFinancialGrid()
        {
            _financialData = FinancialData.GetFinancialData();
            var view = new MyCollectionView(_financialData);

            _flexFinancial.ItemsSource              = view;
            _flexFinancial.Columns.Frozen           = 1;
            _flexFinancial.Columns[0].AllowDragging = false;

            // configure search box
            _srchCompanies.View = view;
            var props = _srchCompanies.FilterProperties;

            props.Add(typeof(FinancialData).GetProperty("Name"));
            props.Add(typeof(FinancialData).GetProperty("Symbol"));

            // show company info
            UpdateCompanyStatus();
            view.CollectionChanged += financial_CollectionChanged;

            UpdateCellFactory();
        }
        // fill unbound grid with data
        void PopulateUnboundGrid()
        {
            var data = new ObservableCollection <Customer>();

            for (int i = 0; i < ROW_COUNT; i++)
            {
                data.Add(new Customer());
            }
            var view = new MyCollectionView(data);
            // allow merging
            var fg = _flexUnbound;

            fg.AllowMerging = AllowMerging.All;
            // add rows/columns to the unbound grid
            for (int i = 0; i < 10; i++)
            {
                fg.Columns.Add(new Column());
            }
            for (int i = 0; i < 50; i++)
            {
                fg.Rows.Add(new Row());
            }

            // populate the unbound grid with some stuff
            for (int r = 0; r < fg.Rows.Count; r++)
            {
                for (int c = 0; c < fg.Columns.Count; c += 10)
                {
                    fg[r, c + 0] = data[r].Name;
                    fg[r, c + 1] = data[r].Country;
                    fg[r, c + 2] = data[r].CountryID;
                    fg[r, c + 3] = data[r].Active;
                    fg[r, c + 4] = data[r].First;
                    fg[r, c + 5] = data[r].Last;
                    fg[r, c + 6] = data[r].Hired.ToShortDateString();
                    fg[r, c + 7] = data[r].Father;
                    fg[r, c + 8] = data[r].Brother;
                    fg[r, c + 9] = data[r].Cousin;
                }
            }

            // add some group rows above the data
            for (int offset = 0; offset < fg.Rows.Count - 10; offset += 10)
            {
                for (int i = 0; i < 3; i++)
                {
                    fg.Rows.Insert(offset + i, new GroupRow()
                    {
                        Level = i
                    });
                    fg[offset + i, 0] = string.Format("level {0}", i);
                }
            }

            // set unbound column headers
            var ch = fg.ColumnHeaders;

            ch.Rows.Add(new Row());
            for (int c = 0; c < ch.Columns.Count; c++)
            {
                ch[0, c] = "Customer Infomation";
            }
            ch[1, 0] = "Name";
            ch[1, 1] = "Country";
            ch[1, 2] = "CountryID";
            ch[1, 3] = "Active";
            ch[1, 4] = "First";
            ch[1, 5] = "Last";
            ch[1, 6] = "Hired";
            ch[1, 7] = "Father";
            ch[1, 8] = "Brother";
            ch[1, 9] = "Cousin";

            // allow merging the first fixed row
            ch.Rows[0].AllowMerging = true;

            // set unbound row headers
            var rh = fg.RowHeaders;

            //rh.Columns.Add(new Column());
            for (int c = 0; c < rh.Columns.Count; c++)
            {
                rh.Columns[c].Width = new GridLength(60);
                for (int r = 0; r < rh.Rows.Count; r++)
                {
                    if (!(rh.Rows[r] is GroupRow))
                    {
                        int level = (r % 3 > 1) ? 1 : 2;
                        rh[r, c] = "VIP" + level.ToString();
                    }
                }
            }

            // allow merging the first fixed column
            rh.Columns[0].AllowMerging = true;

            // listen to column resized event
            _flexUnbound.ResizedColumn += _flexUnbound_ResizedColumn;
        }