This is a migrated thread and some comments may be shown as answers.

WPF Gridview Filter with Image and Text

1 Answer 237 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Patrick Baggett
Top achievements
Rank 2
Patrick Baggett asked on 02 Nov 2016, 05:07 PM

I need to display grid filters with both an image and descriptive text.  I've searched the forum and found numerous examples for adding the image, but none with both image and text.

Is this possible?  if not, can I reduce the width of the filter dropdown to avoid the "ugly" whitespace in my filter list?  There is really no need to include the "Apply" and "Clear" filter buttons as the check boxes auto apply the filters when checked or unchecked.

Here is what I have so far:

 

    public class ImageFilterColumn : GridViewImageColumn
    {
        protected override Func<object, object> FilteringDisplayFunc => CategoryToFilterImage;

        public static object CategoryToFilterImage(object value)
        {
            var rtn = new object();
            var cat = (LogCategory) value;
            var image = new Image() {Source = new BitmapImage(cat.ToSmallImageUri())};
            return image;
        }
    }

xaml:

 <telerik:RadGridView.Columns>
 <local:ImageFilterColumn ShowFieldFilters="False" Header ="" DataMemberBinding="{Binding cat, Converter={StaticResource CategoryImageConverter}}"/>

 

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 07 Nov 2016, 09:15 AM
Hello,

You can achieve your goal by modifying the template of our FilteringControl. The distinct values are in ListBox which ItemTemplate is a checkbox. You can modify this ItemTemplate to include your image. As for the other parts of the FIlteringControl - you can remove the mentioned buttons directly from the template. I have prepared a sample project, using our Implicit Styles, which demonstrates the approach. You can check the changes I made in the "FilteringControlTemplate" in the Themes/Telerik.Windows.Controls.GridView. file.

Regards,
Yoan
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
Tags
GridView
Asked by
Patrick Baggett
Top achievements
Rank 2
Answers by
Yoan
Telerik team
Share this question
or