1
當值超過最小值或最大值時,WP7 ProgressBar的視覺方面將停止工作。特別是,當超過最小值或最大值,然後該值稍後返回到最小值和最大值之間的值時,ProgressBar要麼完全黑暗或完全填充(分別爲最小值和最大值)。當值超過最小值或最大值時,WP7 ProgressBar會中斷
這是我的測試如果您有任何人有興趣重現這一點,請填寫代碼。我如何解決這個問題?
順便說一句,我應該補充說我的最小值和最大值有所不同,有時價值自然會超過這些值。
XAML:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Click="Button_Click" Width="150" Height="100" VerticalAlignment="Top">Up</Button>
<Button Click="Button_Click_1" Width="150" Height="100" VerticalAlignment="Top" HorizontalAlignment="Right">Down</Button>
<ProgressBar x:Name="PBar" Value="{Binding Progress}" Maximum="{Binding Maximum}"></ProgressBar>
<TextBlock Text="{Binding Progress}" VerticalAlignment="Bottom"/>
</Grid>
C#:
using System.ComponentModel;
public partial class MainPage : PhoneApplicationPage, INotifyPropertyChanged
{
// Constructor
public MainPage()
{
InitializeComponent();
this.LayoutRoot.DataContext = this;
Maximum = 100;
}
private int _progress;
public int Progress
{
get { return _progress; }
set
{
_progress = value;
NotifyPropertyChanged("Progress");
}
}
private int _maximum;
public int Maximum
{
get { return _maximum; }
set
{
_maximum = value;
NotifyPropertyChanged("Maximum");
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{ PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); }
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Progress += 10;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Progress -= 10;
}
}
嗯,我最終修改了我的DomainModel,以便我的XAML綁定到一個不同的屬性,檢查是否超過最小值和最大值,如果是,只返回最小值或最大值。這就是說,這仍然是一個惱人的錯誤,恕我直言。 – Pretzel 2012-02-19 21:02:28
您可以嘗試用於Windows Phone的Silverlight工具中的PerformanceProgressBar。它可能會更好。 – gbanfill 2012-02-19 22:29:17