Creating custom columns for RadGridView is super easy - all you need to do is to override CreateCellElement and/or CreateCellEditElement methods and return desired controls. To illustrate this I’ve made a column with RadProgressBar for view mode and RadSlider for edit mode:
 CustomPercentageColumn

And here is the code:

public class GridViewPercentageColumn : GridViewDataColumn
{
    public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
    {
        var bar = cell.Content as RadProgressBar;

        if (bar == null)
        {
            bar = new RadProgressBar();
            bar.Height = 20;
            bar.SetBinding(RadProgressBar.ValueProperty, this.DataMemberBinding);
            cell.Content = bar;
        }

        return bar;
    }

    public override FrameworkElement CreateCellEditElement(GridViewCell cell, object dataItem)
    {
        var slider = new RadSlider();
        slider.Maximum = 0;
        slider.Maximum = 100;
        slider.SmallChange = 1;
        slider.LargeChange = 10;
        slider.SetBinding(RadSlider.ValueProperty, this.DataMemberBinding);
        return slider;
    }
} 

 

Enjoy!


About the Author

Vladimir Enchev

is Director of Engineering, Native Mobile UI & Frameworks

Comments

Comments are disabled in preview mode.