Windows での InputView 読み取り順序

Download Sampleサンプルのダウンロード

このユニバーサル Windows プラットフォームのプラットフォーム固有の機能により、EntryEditorLabel インスタンスの双方向テキストの読み取り順序 (左から右または右から左) を動的に検出できるようになります。 XAML で、InputView.DetectReadingOrderFromContent (EntryEditor インスタンスの場合) または Label.DetectReadingOrderFromContent 添付プロパティを boolean 値に設定して使用されます。

<ContentPage ...
             xmlns:windows="clr-namespace:Xamarin.Forms.PlatformConfiguration.WindowsSpecific;assembly=Xamarin.Forms.Core">
    <StackLayout>
        <Editor ... windows:InputView.DetectReadingOrderFromContent="true" />
        ...
    </StackLayout>
</ContentPage>

あるいは、Fluent API を使用して C# から使用することもできます。

using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
...

editor.On<Windows>().SetDetectReadingOrderFromContent(true);

Editor.On<Windows> メソッドでは、このプラットフォーム固有設定がユニバーサル Windows プラットフォームでのみ実行されるように指定します。 InputView.SetDetectReadingOrderFromContent メソッドはXamarin.Forms.PlatformConfiguration.WindowsSpecific 名前空間で、InputView のコンテンツから読み取り順序が検出されるかどうかを制御するために使用されます。 さらに、InputView.SetDetectReadingOrderFromContent メソッドを使用すると、現在の値を返す InputView.GetDetectReadingOrderFromContent メソッドを呼び出すことによって、読み取り順序がコンテンツから検出されるかどうかを切り替えることができます。

editor.On<Windows>().SetDetectReadingOrderFromContent(!editor.On<Windows>().GetDetectReadingOrderFromContent());

その結果、EntryEditorLabel インスタンスは、コンテンツの読み取り順序を動的に検出できます。

InputView detecting reading order from content platform-specific

Note

FlowDirection プロパティの設定とは異なり、テキスト コンテンツから読み取り順序を検出するビューのロジックは、ビュー内のテキストの配置には影響しません。 その代わり、双方向テキストのブロックをレイアウトする順序を調整します。