演習 - Power Apps の MR で測定とフィルター処理

完了

このユニットでは、Power Apps の主要な機能コンポーネントの一部を使用します。 これには、MR で測定とフィルター方法が含まれます。 ユーザーは、Power Apps の MR で測定コンポーネントを使用して、現実世界の距離、面積、体積を測定できます。

MR で測定を使用した空間フィルター

MR で測定機能は、測定セッションを通して受け取った測定値に従って現実世界に簡単に配置できるように、製品を空間的にフィルター処理するために使用されます。 このフィルター処理の実行には、いくつかの基本的な数式が使用されます。

  1. Home page に移動します。 [挿入] タブで、[Mixed Reality] ドロップダウンを展開し、[MR 内のメジャー] を選択します。

    MR で測定を追加するスクリーンショット

  2. 図に示すように [MR で測定] ボタンを配置し、次のプロパティを構成します。

    • テキスト: Filter by Dimensions
    • 測定単位: Centimeters
    • 測定の種類: Freeform

    MR 内のメジャーのプロパティの構成のスクリーンショット。

  3. [ギャラリー]>[縦] を選択して Home pageギャラリーを追加します。 ギャラリーの名前を Measure_gallery に変更します。

    ギャラリーの追加のスクリーンショット。

  4. [垂直ギャラリー][Filter by Dimensions] ボタンのすぐ下に配置します。 [タイトル、サブタイトル、本文] を選択して [レイアウト] プロパティを構成します。

    レイアウトを構成するスクリーンショット

  5. 次の行を追加して、Measure_galleryItems プロパティを構成します。

    MeasureInMR1.Measurements
    

    ギャラリーのデータ ソースのスクリーンショット。

  6. SeparatorNextArrow を削除します。 画像に示すように、タイトルサブタイトル本文を互いに等間隔に配置します。

    等間隔な配置のスクリーンショット。

  7. 3 つのラベルの Text プロパティを次のように構成します。

    • タイトル:

      "Unit: "&ThisItem.Unit
      

      タイトル テキストのスクリーンショット

    • サブタイトル:

      "Area: "&ThisItem.Area&"cm²"
      

      サブタイトル テキストのスクリーンショット。

    • 本文は次のようになります。

      "Height: "&ThisItem.Height&"cm"
      

      本文テキストのスクリーンショット。

  8. ユーザーが測定に不満足な場合に再実行できるように、[再読み込み] アイコンを追加しましょう。 [挿入] タブで、[アイコン] ドロップダウンを展開し、[再読み込み] アイコンを選択します。

    再読み込みアイコンの追加のスクリーンショット。

  9. 次の図に示すようにアイコンを配置し、OnSelect プロパティを次のように構成します。

    UpdateContext({galleryvisible:false});
    

    再読み込みアイコンの OnSelect の構成のスクリーンショット。

    ヒント

    アプリケーションのデザインに合わせてフォント、フォント サイズ、フォント スタイルをカスタマイズできます。 ただし、ユーザー エクスペリエンス向上のために、アプリケーション全体で一貫したフォントを維持します。

  10. MR で測定コンポーネントを完全に構成したら、空間フィルターに進みます。 ここでは、MR で測定セッションで受け取った WidthDepthHeight の値に基づいて、空間フィルターを適用します。

    [製品] ページに移動した後、Gallery_productsItems プロパティを次のように構成します。

    If(
    ID = 1 And Measure_gallery.Selected.Height = 0,
    (Filter('Easy Sales',(ProductCategory = "Sofa") And ((Depth < Measure_gallery.Selected.BoundingDepth And Width < Measure_gallery.Selected.BoundingWidth) Or (Depth < Measure_gallery.Selected.BoundingWidth And Width < Measure_gallery.Selected.BoundingDepth)))),
    ID = 1 And Measure_gallery.Selected.Height > 0,
    (Filter('Easy Sales',(ProductCategory = "Sofa") And ((Depth < Measure_gallery.Selected.BoundingDepth And Width < Measure_gallery.Selected.BoundingWidth And Height <= Measure_gallery.Selected.Height) Or (Depth < Measure_gallery.Selected.BoundingWidth And Width < Measure_gallery.Selected.BoundingDepth And Height <= Measure_gallery.Selected.Height)))),
    ID = 1,
    Filter('Easy Sales',ProductCategory = "Sofa"), 
    
    ID = 2,
    Filter('Easy Sales',ProductCategory = "Chair"), 
    ID = 2 And Measure_gallery.Selected.Height = 0,
    (Filter('Easy Sales',(ProductCategory = "Chair") And ((Depth < Measure_gallery.Selected.BoundingDepth And Width < Measure_gallery.Selected.BoundingWidth) Or (Depth < Measure_gallery.Selected.BoundingWidth And Width < Measure_gallery.Selected.BoundingDepth)))),
    ID = 2 And Measure_gallery.Selected.Height > 0,
    (Filter('Easy Sales',(ProductCategory = "Chair") And ((Depth < Measure_gallery.Selected.BoundingDepth And Width < Measure_gallery.Selected.BoundingWidth And Height <= Measure_gallery.Selected.Height) Or (Depth < Measure_gallery.Selected.BoundingWidth And Width < Measure_gallery.Selected.BoundingDepth And Height <= Measure_gallery.Selected.Height)))),
    
    ID = 3,
    Filter('Easy Sales',ProductCategory = "Table"),
    ID = 3 And Measure_gallery.Selected.Height = 0,
    (Filter('Easy Sales',(ProductCategory = "Table") And ((Depth < Measure_gallery.Selected.BoundingDepth And Width < Measure_gallery.Selected.BoundingWidth) Or (Depth < Measure_gallery.Selected.BoundingWidth And Width < Measure_gallery.Selected.BoundingDepth)))),
    ID = 3 And Measure_gallery.Selected.Height > 0,
    (Filter('Easy Sales',(ProductCategory = "Table") And ((Depth < Measure_gallery.Selected.BoundingDepth And Width < Measure_gallery.Selected.BoundingWidth And Height <= Measure_gallery.Selected.Height) Or (Depth < Measure_gallery.Selected.BoundingWidth And Width < Measure_gallery.Selected.BoundingDepth And Height <= Measure_gallery.Selected.Height))))
    )
    

    ソファ内の項目の構成のスクリーンショット。

    重要

    今後間違えることがないように、SharePoint リストとギャラリーに適切な名前を付けます。 混乱を避けるために、数式内のコンポーネントの名前を維持します。

    Note

    Carpets ページには空間フィルターは含まれていません。この製品に固有の別の機能が追加されているためです。 MR で測定セッションで測定された面積が、選択したカーペットの価格を見積もるために使用されます。

    ヒント

    上部にある [ファイル] タブを選択し、[保存] オプションを選択して、アプリケーションを頻繁に保存します。 メッセージが表示されたら [クラウド] オプションを選択し、次に [保存] を選択します。

面積に基づいて価格を計算する

  1. Carpet_details ページに移動してから、ラベルを追加し、次に Area_carpets という名前に変更します。

    面積ラベルを追加しているスクリーンショット

  2. Area_carpets ラベルの横に空白のラベルをもう 1 つ追加してから、その空白ラベルの Text プロパティを次のように構成して、計算された面積を表示するようにします。

    Measure_gallery.Selected.Area&"cm²"
    

    面積計算のスクリーンショット。

  3. Price ラベルの横のラベルを次のように構成し、計算された価格を表示するようにします。

    "$"&Measure_gallery.Selected.Area * content_carpets.'Price/cm2'
    

    価格計算のスクリーンショット。

上記の手順を実装した後、アプリケーションによって、製品が空間的にフィルター処理され、実世界の測定値に基づいてカーペットの正確な価格が計算されます。

MR 内のメジャーと空間フィルタリングを実装した後のアプリケーション デモのアニメーション。