Windows フォーム アプリケーションのプログレス バーには標準の「光る」アニメーションがありますが、WPF にプログレス バーを追加しようとすると、既定ではそのようなアニメーションが表示されません。Windows 8 の WPF でこれを取り戻すにはどうすればよいですか?
Windows フォーム
WPF
Windows フォーム アプリケーションのプログレス バーには標準の「光る」アニメーションがありますが、WPF にプログレス バーを追加しようとすると、既定ではそのようなアニメーションが表示されません。Windows 8 の WPF でこれを取り戻すにはどうすればよいですか?
Windows フォーム
WPF
これはかなり奇妙な修正ですが、「光沢」を使用するには、アプリケーションで Windows フォーム スタイルを有効にする必要があります。これが私がやった方法です。
System.Windows.Forms
View Application Events
Application.Startup
(VB.NET では C# と同様) (また、引数を含める必要がある場合はそうしてください)。Class Application
' Application-level events, such as Startup, Exit, and DispatcherUnhandledException
' can be handled in this file.
Private Sub Application_Startup() Handles Me.Startup
System.Windows.Forms.Application.EnableVisualStyles()
End Sub
End Class
WPFプログレスバーを機能させるためにこれを呼び出さなければならないのは奇妙に思えますが、コードは私にとってはうまくいきます。
外観 (つまり、インジケーターの色) を完全に制御したい場合は、別の SO 投稿で見つけたコントロールを微調整しました。これにより、ほぼ同じ表示が得られます。
微調整:
<Grid Background="LightGray">
<Grid Width="{Binding ProgressBarWidth, ElementName=uc}" HorizontalAlignment="Left">
<Grid.Triggers>
<EventTrigger RoutedEvent="Rectangle.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Background.(GradientBrush.GradientStops)[1].(GradientStop.Offset)" From="-1" To="0" Duration="0:0:1.5" RepeatBehavior="Forever"/>
<DoubleAnimation Storyboard.TargetProperty="Background.(GradientBrush.GradientStops)[2].(GradientStop.Offset)" From="0" To="1" Duration="0:0:1.5" RepeatBehavior="Forever"/>
<DoubleAnimation Storyboard.TargetProperty="Background.(GradientBrush.GradientStops)[3].(GradientStop.Offset)" From="1" To="2" Duration="0:0:1.5" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
<Grid.Background>
<LinearGradientBrush>
<GradientStop Color="#FF218ED6" Offset="0.0" />
<GradientStop Color="#FF4BA5E0" Offset="0.4" />
<GradientStop Color="#FF8ECCF5" Offset="0.5" />
<GradientStop Color="#FF4BA5E0" Offset="0.6" />
<GradientStop Color="#FF218ED6" Offset="1.0" />
</LinearGradientBrush>
</Grid.Background>
</Grid>
</Grid>
完全な実装:
WPF の進行状況バーのスタイルは時代遅れです。バーの増分。vista または windows-7 の影付きグロー効果を使用してプログレス バーを実装する方法は?
プレビュー: