• Revista PROGRAMAR: Já está disponível a edição #53 da revista programar. Faz já o download aqui!

SoulOnFire

FiveStarRating em c# / WPF

1 mensagem neste tópico

Boas!

Deixo-vos aqui um pequeno controlo que desenvolvi para podermos facilmente transformar qualquer pontuação numa Five Star Rating

Para isso basta definir as propriedades Value e Maximum e automaticamente temos uma FiveStarRating.

Este é o codigo do CostumControl, apenas acrescentei ao uma progressbar a propriedade FrontStarBackground, que permite definir a cor das estrelas.


public class FiveStarRating : ProgressBar
    {
        static FiveStarRating()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(FiveStarRating), new FrameworkPropertyMetadata(typeof(FiveStarRating)));
        }

        #region Properties

        public Brush FrontStarBackground
        {
            get { return (Brush)GetValue(FrontStarBackgroundProperty); }
            set { SetValue(FrontStarBackgroundProperty, value); }
        }

        // Using a DependencyProperty as the backing store for FrontStarBackground.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty FrontStarBackgroundProperty =
            DependencyProperty.Register("FrontStarBackground", typeof(Brush), typeof(FiveStarRating), new UIPropertyMetadata(Brushes.YellowGreen));
        #endregion
    }

Precisamos também deste converter, para quem não sabe trata-se de uma propriedade de Binding onde podemos definir que tipo de conversão queremos para o valor ao qual definimos Binding. Neste caso trata-se de um MultivalueConverter (http://msdn.microsoft.com/en-us/library/system.windows.data.imultivalueconverter.aspx)

public class ConvertValue:IMultiValueConverter   
    {  

        #region IMultiValueConverter Members   
  
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)   
        {   
            double value = double.Parse(values[0].ToString());   
            double maximum = double.Parse(values[1].ToString());   
            double actualWidth = double.Parse(values[2].ToString());   
  
            return value * actualWidth / maximum;   
        }   
  
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)   
        {   
            return null;   
        }  

        #endregion   
    }  

<local:ConvertValue x:Key="ConvertValue"/>  
   <Style TargetType="{x:Type local:FiveStarRating}">  
       <Setter Property="Template">  
           <Setter.Value>  
               <ControlTemplate TargetType="{x:Type local:FiveStarRating}">  
                   <Border  
                           BorderThickness="{TemplateBinding BorderThickness}">  
                       <Grid>  
                           <StackPanel Orientation="Horizontal" x:Name="_panelDark" HorizontalAlignment="Left">  
                               <Path  Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >  
  
                               </Path>  
                               <Path Fill="{TemplateBinding Background}"  Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >  
  
                               </Path>  
                               <Path  Fill="{TemplateBinding Background}"  Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >  
  
                               </Path>  
                               <Path  Fill="{TemplateBinding Background}"  Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >  
  
                               </Path>  
                               <Path  Fill="{TemplateBinding Background}"  Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >  
  
                               </Path>  
                           </StackPanel>  
                           <StackPanel Orientation="Horizontal"  Grid.Row="1" x:Name="_panelLight" HorizontalAlignment="Left">  
                               <StackPanel.MaxWidth>  
                                   <MultiBinding Converter="{StaticResource ConvertValue}">  
                                       <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Value" />  
                                       <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Maximum"/>  
                                       <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ActualWidth"/>  
                                   </MultiBinding>  
                               </StackPanel.MaxWidth>  
                               <Path Fill="{TemplateBinding FrontStarBackground}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >  
  
                               </Path>  
                               <Path Fill="{TemplateBinding FrontStarBackground}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >  
  
                               </Path>  
                               <Path Fill="{TemplateBinding FrontStarBackground}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >  
  
                               </Path>  
                               <Path Fill="{TemplateBinding FrontStarBackground}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >  
  
                               </Path>  
                               <Path Fill="{TemplateBinding FrontStarBackground}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >  
  
                               </Path>  
  
                           </StackPanel>  
                       </Grid>  
                   </Border>  
               </ControlTemplate>  
           </Setter.Value>  
       </Setter>  
   </Style>  

Para utilizarmos basta

<local:FiveStarRating HorizontalAlignment="Left" Height="12"  
Background="Black" FrontStarBackground="DarkOrange" Maximum="10"  
Value="{Binding Path=RatingImdb}"/>

Aproveito para vos deixar um screen de algo que estou a desenvolver onde ja aplico este controlo

screenwpfdesktop.jpg

http://akitoueu.no.sapo.pt/FiveStarRatingTest.zip

Mais infos e mais controlos no meu Blog!

Cumprimentos,

MiguelDuarte

0

Partilhar esta mensagem


Link para a mensagem
Partilhar noutros sites

Crie uma conta ou ligue-se para comentar

Só membros podem comentar

Criar nova conta

Registe para ter uma conta na nossa comunidade. É fácil!


Registar nova conta

Entra

Já tem conta? Inicie sessão aqui.


Entrar Agora