c# XAML ProgressBar set gradient filling properly -
c# XAML ProgressBar set gradient filling properly -
how set gradient of progressbar
in xaml dynamic filling?
at moment like:
code both progress bars:
<progressbar.foreground> <lineargradientbrush endpoint="0.5,1" startpoint="0.5,0"> <lineargradientbrush.relativetransform> <compositetransform centery="0.5" centerx="0.5" rotation="270"/> </lineargradientbrush.relativetransform> <gradientstop color="lime" offset="0"/> <gradientstop color="red" offset="1"/> </lineargradientbrush> </progressbar.foreground>
but want have "end"color of upper progressbar
in green-yellowish color straight below. means want progress bar total filled sec bar , "cut" rest out (e.g. when have 60% want 40% on right not shown)
how do properly?
edit (found solution):
after trying couple of ways (drawing rectangle default color onto bar etc) figured out can modify offset
of gradientstop
code:
color_ul.offset = 2.0 - ul_val / 100;
means subtract percentage want display e.g. 30% (ul_val = 30
) offset set 170% (1.7) bar shows 30% smooth , right color gradient. if have 100% on bar calculates 2.0 - 1.0
1 (like normal, shown in bar #2 in image 1).
i know sounds confusing, here image wanted be:
my solution:
after trying couple of ways (drawing rectangle default color onto bar etc) figured out can modify offset
of gradientstop
code:
color_ul.offset = 2.0 - ul_val / 100;
means subtract percentage want display e.g. 30% (ul_val = 30
) offset set 170% (1.7) bar shows 30% smooth , right color gradient. if have 100% on bar calculates 2.0 - 1.0
1 (like normal, shown in bar #2 in image 1).
i know sounds confusing, here image wanted be:
c# xaml progress-bar gradient
Comments
Post a Comment