How to create a rating column ?

Apr 19, 2009 at 10:43 AM
Edited Apr 19, 2009 at 6:57 PM
Hi !

I just start WPF few days ago and i'm using your amazing DataGrid ! ^^

My XAML code :
<toolkit:DataGrid LoadingRow="DGFilms_LoadingRow" Name="DGFilms" Grid.Row="1" Grid.ColumnSpan="4" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeRows="False" >
                    <StackPanel Orientation="Horizontal">
                        <Image Source="{Binding Path=Affiche}"></Image>
                        <TextBlock Width="500"  Text="{Binding Path=Synopsis}" TextWrapping="Wrap"></TextBlock>
                <toolkit:DataGridTextColumn Header="Nom" Binding="{Binding Path=Nom}" ></toolkit:DataGridTextColumn>
                <toolkit:DataGridTextColumn Header="Genre" Binding="{Binding Path=Genre}"></toolkit:DataGridTextColumn>
                <toolkit:DataGridTextColumn Header="Durée" Binding="{Binding Path=Duree}"></toolkit:DataGridTextColumn>
                <toolkit:DataGridTextColumn Header="Année" Binding="{Binding Path=Annee}"></toolkit:DataGridTextColumn>
                <toolkit:DataGridCheckBoxColumn Header="Fichier LD" Binding="{Binding Path=FichierLd}"></toolkit:DataGridCheckBoxColumn>
                <toolkit:DataGridCheckBoxColumn Header="Fichier HD" Binding="{Binding Path=FichierHd}"></toolkit:DataGridCheckBoxColumn>
                <toolkit:DataGridCheckBoxColumn Header="DVD" Binding="{Binding Path=DVD}"></toolkit:DataGridCheckBoxColumn>
                <toolkit:DataGridCheckBoxColumn Header="BluRay" Binding="{Binding Path=Bluray}"></toolkit:DataGridCheckBoxColumn>
                <toolkit:DataGridCheckBoxColumn Header="VF" Binding="{Binding Path=Vf}"></toolkit:DataGridCheckBoxColumn>
                <toolkit:DataGridCheckBoxColumn Header="VOST" Binding="{Binding Path=Vost}"></toolkit:DataGridCheckBoxColumn>
                <toolkit:DataGridTemplateColumn Header="Note" >
                            <StackPanel Orientation="Horizontal">
                                <Image Name="Star1" Source="\Ressources\star.png"></Image>
                                <Image Name="Star2" Source="\Ressources\star.png"></Image>
                                <Image Name="Star3" Source="\Ressources\star.png"></Image>
                                <Image Name="Star4" Source="\Ressources\star.png"></Image>
                                <Image Name="Star5" Source="\Ressources\star.png"></Image>
                <toolkit:DataGridTextColumn Header="Commentaire" Binding="{Binding Path=Observation}"></toolkit:DataGridTextColumn>

I need to change Source of images. If the note is 2 i need to "draw" three empty stars.
I'm actually searching on LoadingRow event , but i don't know how can i do. What is the better way ?
What event do i use to click on star and change the value of the note ?

Thanks in advance ;)
Apr 20, 2009 at 5:51 PM
After some research i found nothing. I'm trying to get the celltemplate but i don't find any way. :/
I'm using the event LoadingRow i can acces to my item with (e.Row.Item as Film) but i can't access to my images Star1 etc in the cell ?

How can i do that ?

Apr 21, 2009 at 12:08 PM
I edit the subject of the topic.

I need to create a rating column. Value need to be change on user click.  I have empty stars to do that.
First Need : How to display rating ? Image are a good way or not ? How can i bind my value (integer) ?
Second need : How to change the rating ? Event ?

I just need to be on the right track.

Thanks in advance (From France).
Apr 21, 2009 at 12:41 PM
Jaime's datagrid sample post,, has something similar to what you are trying to do.  Maybe that can help you out.
Apr 21, 2009 at 12:57 PM
He use a combobox (enum) to define the number of draw star.
I want only one column.

There is a way to access to my images in DataTemplate on LoadingRow event ?
Apr 21, 2009 at 8:25 PM
There's a different ratings control in the Southridge lab, Part 6 DataGrid (available under the WPF Futures:  This control is similar to the editable ratings control used on or  You might want to see if this control works better for your scenario.