bbweiners Posted January 31, 2018 Share Posted January 31, 2018 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> Quote Link to comment Share on other sites More sharing options...
bbweiners Posted January 31, 2018 Author Share Posted January 31, 2018 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> Quote Link to comment Share on other sites More sharing options...
bbweiners Posted January 31, 2018 Author Share Posted January 31, 2018 @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}" ... /> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.