i trying write component show rating via number of star images hold, example put 5 stars rating of 5. there way can define creation of these stars loop in xaml or have programatically in code behind? asking that, there way incorporate conditional logic inside xaml?
is there way incorporate conditional logic inside xaml?
yes , no. can use datatriggers actioned if condition met, unnecessary need do.
i use list control, , in content template items have image control uses star source. bind list control collection (i.e. list<int>
) has 1 item per star. if possible have fractions of stars approach best - use list<decimal>
instead of int, adjust item template show appropriate image fractional number.
alternatively if have int
property contains number of stars, there 2 approaches:
- have image control has max stars + 1 datatriggers, , set source of image appropriate image file. suboptimal method because datatriggers evaluated.
- use image control converter returns appropriate source uri based on number of stars.
Comments
Post a Comment