<ProgressBar Value="{Bi开发者_如何学Pythonnding Player1PointsLife}" Minimum="0" Maximum="8000"/>
Why when value exceeds maximum or minimun, it doens't update the UI anymore? How can I fix it? Thanks in advance.
UPDATE: Maybe I was not very clear. I mean, I set in progress bar value = 2000 (all right, updates de UI), then I set -1000 (it's correct, it mustn't show anything in the progress bar), and finally I set 6000 (here must updates the UI, but it isn't updating anymore).
Write a WPF converter so that if the value is >8000 or <0 it sets the value according to your requirement. Set the converter as follows in XAML:
<ProgressBar Value="{Binding Player1PointsLife, Converter={StaticResource **YourConverter**}}" Minimum="0" Maximum="8000"/>
What should it do? It can't show the progress bar any more empty than fully empty or any more full than completely full. You can fix it by telling the progress bar what you want it to do. If you want it to appear, say, 85% full, set the value to 85% of the way from the minimum to the maximum.
The usual way to do this for a stat in a game is to raise the maximum to the player's current maximum for that stat. If you allow the stat to go over the normal maximum for some reason (say a special power up), you have to decide how you want to display that. Maybe you can change the bar color and raise the maximum to the temporary maximum. Maybe you can add an additional bar to show the "overflow" power. Whatever works for your concept.
精彩评论