WPF Gridview Filter with Image and Text

2 posts, 0 answers
  1. Patrick Baggett
    Patrick Baggett avatar
    9 posts
    Member since:
    Aug 2012

    Posted 02 Nov Link to this post

    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}}"/>

     

  2. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 07 Nov Link to this post

    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.xaml file.

    Regards,
    Yoan
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top