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

How to use GIF in RadGridView

1 Answer 53 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sergey
Top achievements
Rank 1
Sergey asked on 21 Jul 2019, 09:27 PM

Hello,

I'm trying to implement GIF for my GridView but it isn't animated. Does GridView support GIFs?

My example:

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:NotWorkingGif"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="NotWorkingGif.MainWindow"
        mc:Ignorable="d"
        DataContext="{Binding RelativeSource={RelativeSource Self}}"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <telerik:RadGridView ItemsSource="{Binding Collection}" AutoGenerateColumns="False">
            <telerik:RadGridView.Columns>
                <telerik:GridViewImageColumn DataMemberBinding="{Binding ImageUri}" Header="" ImageStretch="None" ImageHeight="16" ImageWidth="16" />
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</Window>

namespace NotWorkingGif
{
    using System;
    using System.Collections.ObjectModel;
    using System.ComponentModel;
    using System.Windows;

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public ObservableCollection<TestClass> Collection { get; set; } = new ObservableCollection<TestClass>();

        public MainWindow()
        {
            InitializeComponent();

            this.Collection.Add(new TestClass() { ImageUri = new Uri(@"path to GIF image") });
        }
    }

    public class TestClass : INotifyPropertyChanged
    {
        private Uri imageUri;
        public Uri ImageUri
        {
            get => imageUri;

            set
            {
                imageUri = value;
                this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ImageUri"));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}


1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 24 Jul 2019, 08:34 AM
Hello Sergey,

Even though the RadGridView control does not provide support for GIF images out of the box, you can use one of the approaches suggested in this thread to display animated images in your columns by using their CellTemplate property or probably creating your own custom GIF column.

For your convenience, I've prepared a small sample project which uses the WpfAnimatedGif library.

Please have a look and let me know whether this, or any of the other proposed solutions would work for you.

Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Sergey
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or