WPF:プログレスバーに問題があります。操作が完了していないときに表示し、操作が完了すると非表示になります。私の仕事に適用できるように、わかりやすい例を示してください。前もって感謝します!
5249 次
2 に答える
2
さまざまなシナリオでそれを行うことができます。
トリガーを使用する(私はそれを好む)
<ProgressBar Maximum="100" Margin="10,107,232,168" Value="0" Name="progr"> <ProgressBar.Resources> <Style TargetType="{x:Type ProgressBar}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Value}" Value="100"> <Setter Property="Visibility" Value="Hidden"/> </DataTrigger> </Style.Triggers> </Style> </ProgressBar.Resources> </ProgressBar>
コンバーターの使用
<Grid> <Grid.Resources> <delWpf:VisibilityConverter x:Key="conv"/> </Grid.Resources> <ProgressBar Name="prog2" Minimum="0" Maximum="100" Value="{Binding CurrentIndex, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding RelativeSource={RelativeSource Self}, Path=Value, Mode=OneWay, Converter={StaticResource conv}}" /> </Grid>
とコンバーター
public class VisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return Math.Abs((double)value - 100) < 0.001 ? Visibility.Hidden : Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
于 2012-07-17T05:51:35.827 に答える
1
BusyIndicator コントロールを持つ Extended WPF Toolkit を使用する場合があります。
http://wpftoolkit.codeplex.com/wikipage?title=BusyIndicator
サンプルはダウンロードに含まれています。
参考までに、Microsoft はまず Silverlight に BusyIndicator を導入しました (ただし、WPF 用の BusyIndicator は出荷されていません)。
于 2012-07-17T09:03:13.470 に答える