Jump to content
LaunchBox Community Forums

Community Star Rating in a Theme


bbweiners

Recommended Posts

Hi,

Could anyone tell me how to make my theme populate star ratings with community ratings that aren't whole numbers? Right now the only ratings that populate are whole number ratings. So for example, 3.124598 won't populate. Is there a way to make it round to 3.1?

Thanks!

<!--STAR RATING-->
            <Viewbox Grid.Column="11" Grid.Row="4" Grid.ColumnSpan="4" StretchDirection="DownOnly" HorizontalAlignment="Left" Panel.ZIndex="101" Margin="0,0,0,0" VerticalAlignment="Center">
            </Viewbox>
            <Image Grid.Column="15" Grid.Row="4" Grid.ColumnSpan="4" RenderOptions.BitmapScalingMode="HighQuality" Panel.ZIndex="101" >
                <Image.Style>
                    <Style TargetType="Image">
                        <Setter Property="Source" Value="pack://siteoforigin:,,,/Themes/Custom/Images/Theme/0.png" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding SelectedGame.CommunityStarRating}" Value="1" >
                                <Setter Property="Source" Value="pack://siteoforigin:,,,/Themes/Custom/Images/Theme/1.png" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SelectedGame.CommunityStarRating}" Value="2" >
                                <Setter Property="Source" Value="pack://siteoforigin:,,,/Themes/Custom/Images/Theme/2.png" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SelectedGame.CommunityStarRating}" Value="3" >
                                <Setter Property="Source" Value="pack://siteoforigin:,,,/Themes/Custom/Images/Theme/3.png" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SelectedGame.CommunityStarRating}" Value="4" >
                                <Setter Property="Source" Value="pack://siteoforigin:,,,/Themes/Custom/Images/Theme/4.png" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SelectedGame.CommunityStarRating}" Value="5" >
                                <Setter Property="Source" Value="pack://siteoforigin:,,,/Themes/Custom/Images/Theme/5.png" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Image.Style>
            </Image>           

Link to comment
Share on other sites

I understand that if I want ratings to round to the nearest .1 that I have to add more DataTriggers. Example --

<DataTrigger Binding="{Binding SelectedGame.CommunityStarRating}" Value="3" >
                                <Setter Property="Source" Value="pack://siteoforigin:,,,/Themes/Custom/Images/Theme/3.png" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SelectedGame.CommunityStarRating}" Value="3.1" >
                                <Setter Property="Source" Value="pack://siteoforigin:,,,/Themes/Custom/Images/Theme/3.1.png" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SelectedGame.CommunityStarRating}" Value="3.2" >
                                <Setter Property="Source" Value="pack://siteoforigin:,,,/Themes/Custom/Images/Theme/3.2.png" />
                            </DataTrigger>

Link to comment
Share on other sites

@NJDave71 showed me a very easy and more efficient way to solve this problem.

 

<TextBlock x:Name="tbCSRImage"  Visibility="Collapsed">
  <TextBlock.Text>
    <MultiBinding StringFormat="{}pack://siteoforigin:,,,/Themes/Aeon Nox/Images/etc/score/{0:F1}.png">
	  <Binding Path="ActiveGame.CommunityOrLocalStarRating" />
    </MultiBinding>
  </TextBlock.Text>
</TextBlock>								
<Image Source="{Binding Text, ElementName=tbCSRImage}" ... />

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...