Xaml-progressring

提供:Dev Guides
移動先:案内検索

XAML-ProgressRing

ProgressRingは、進行中の操作を示すコントロールです。 典型的な視覚的外観は、進行が進むにつれてアニメーションを循環させるリング状の「スピナー」です。 ここで重要な点は、WPFプロジェクトがProgressRingをサポートしていないことです。 したがって、この制御のために、Windowsストアアプリで作業します。 ProgressRingクラスの階層的な継承は次のとおりです-

ProgressRing Hierarchy

プロパティ

以下に、ProgressRingの一般的に使用されるプロパティを示します。

Sr.No. Property & Description
1

IsActive

ProgressRingが進行状況を表示しているかどうかを示す値を取得または設定します。

2

IsActiveProperty

IsActive依存プロパティを識別します。

3

TemplateSettings

ProgressRingコントロールのテンプレートを定義するときにTemplateBindingソースとして参照できる計算値を提供するオブジェクトを取得します。

イベント

ProgressRingクラスで一般的に使用されるイベントを以下に示します。

Sr.No. Event & Description
1

ManipulationCompleted

UIElementの操作が完了したときに発生します。 (UIElementから継承)

2

ManipulationDelta

入力デバイスが操作中に位置を変更すると発生します。 (UIElementから継承)

3

ManipulationInertiaStarting

入力デバイスが操作中にUIElementオブジェクトとの接触を失い、慣性が始まると発生します。 (UIElementから継承)

4

ManipulationStarted

入力デバイスがUIElementで操作を開始すると発生します。 (UIElementから継承)

5

ManipulationStarting

操作プロセッサが最初に作成されたときに発生します。 (UIElementから継承)

6

ValueChanged

範囲の値が変更されたときに発生します。 (RangeBaseから継承)

方法

以下に、ProgressRingクラスで一般的に使用されるメソッドを示します。

Sr.No. Method & Description
1

OnManipulationCompleted

ManipulationCompletedイベントが発生する前に呼び出されます。 (Controlから継承)

2

OnManipulationDelta

ManipulationDeltaイベントが発生する前に呼び出されます。 (Controlから継承)

3

OnManipulationInertiaStarting

ManipulationInertiaStartingイベントが発生する前に呼び出されます。 (Controlから継承)

4

OnManipulationStarted

ManipulationStartedイベントが発生する前に呼び出されます。 (Controlから継承)

5

OnManipulationStarting

ManipulationStartingイベントが発生する前に呼び出されます。 (Controlから継承)

6

OnMaximumChanged

Maximumプロパティが変更されたときに呼び出されます。 (RangeBaseから継承)

7

OnMinimumChanged

Minimumプロパティが変更されたときに呼び出されます。 (RangeBaseから継承)

次の例は、ToggleSwitchでProgressRingを使用する方法を示しています。 ProgressRingとToggleSwitchを作成および初期化するXAMLのコードを次に示します-

<Page x:Class = "ProgressRing.MainPage"
   xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:local = "using:ProgressRing"
   xmlns:d = "http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc = "http://schemas.openxmlformats.org/markup-compatibility/2006"
   mc:Ignorable = "d">

   <Grid Background = "{ThemeResource ApplicationPageBackgroundThemeBrush}">
      <StackPanel Orientation = "Horizontal" Margin = "342,0,-342,0">
         <ProgressRing x:Name = "progress1"/>
         <ToggleSwitch Header = "ProgressRing Example" OffContent = "Do work"
            OnContent = "Working" Toggled = "ToggleSwitch_Toggled"
            Margin = "0,348,0,347"/>
      </StackPanel>
   </Grid>

</Page>

以下に示すのは、トグルイベントのC#での実装です-

using System;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;

namespace ProgressRing {
   public sealed partial class MainPage : Page {
      public MainPage() {
         this.InitializeComponent();
      }
      private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e) {
         ToggleSwitch toggleSwitch = sender as ToggleSwitch;

         if (toggleSwitch != null) {
            if (toggleSwitch.IsOn == true) {
               progress1.IsActive = true;
               progress1.Visibility = Visibility.Visible;
            } else {
               progress1.IsActive = false;
               progress1.Visibility = Visibility.Collapsed;
            }
         }
      }
   }
}

上記のコードをコンパイルして実行すると、次の出力が生成されます-

ProgressRing出力

上記のサンプルコードを実行し、Windowsアプリの他のプロパティとイベントを試してみることをお勧めします。