Example #1
0
        static void OnRatingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RatingCell cell = (RatingCell)d;

            for (int i = 0; i < cell.Children.Count; i++)
            {
                cell.Children[i].Opacity = i < cell.Rating ? ON : OFF;
            }
        }
Example #2
0
        void img_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            // calculate rating based on the index of the star
            var        star  = sender as ContentControl;
            RatingCell cell  = star.Parent as RatingCell;
            int        index = cell.Children.IndexOf(star);

            if (index > 0 || e.GetCurrentPoint(star).Position.X > star.Width / 3)
            {
                index++;
            }

            // apply the new rating
            cell.Rating = index;
            Animate(star);
        }
        // bind a cell to a range
        public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange range)
        {
            // get row/col
            var row = grid.Rows[range.Row];
            var col = grid.Columns[range.Column];
            var gr  = row as GroupRow;

            // no border for group rows
            if (gr != null)
            {
                bdr.BorderThickness = _emptyThickness;
            }

            // bind first cell in each group row to collapse/expand
            if (gr != null && range.Column == 0)
            {
                BindGroupRowCell(grid, bdr, range);
                return;
            }

            // bind regular data cells
            switch (col.ColumnName)
            {
            // show names with images
            case "Name":
                bdr.Child = new SongCell(row);
                return;

            // show ratings with stars
            case "Rating":
                var song = row.DataItem as Song;
                if (song != null && gr == null)
                {
                    var cell = new RatingCell();
                    cell.SetBinding(RatingCell.RatingProperty, col.Binding);
                    bdr.Child = cell;
                }
                return;
            }

            // default binding
            base.CreateCellContent(grid, bdr, range);
        }
        public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange range)
        {
            // get row/col
            var row = grid.Rows[range.Row];
            var col = grid.Columns[range.Column];

            // bind regular data cells
            switch (col.ColumnName)
            {
            // show ratings with stars
            case "Rating":
                var video = row.DataItem as Video;
                if (video != null)
                {
                    var cell = new RatingCell();
                    cell.SetBinding(RatingCell.RatingProperty, col.Binding);
                    bdr.Child = cell;
                }
                return;
            }

            // default binding
            base.CreateCellContent(grid, bdr, range);
        }