2016-04-12 22 views
0

右から左のスタイル(テキストとレイアウトの両方)のサポートを行う必要があります。私は親のGridのプロパティをすべての子コントロール内に継承したFlowDirection = "RightToLeft"と設定したことを理解しています。 問題は - デフォルト設定があり、アプリで必要なものだけをシフトしますか?または、すべての親の欲望をフラグのあるキングでFlowDirectionに設定し、アラブ諸国などでこのフラグをFlowDirection = "RightToLeft"と設定する必要がありますか?Windows普遍的な右から左へのサポート

答えて

1

右から左への言語をサポートする場合は、左から右へのレイアウトも必要です。子要素に継承されているため、すべての要素のFlowDirectionプロパティを変更する必要はありません。

MSDN

オブジェクトが オブジェクトツリー内の親からの流れ方向の値を継承します。どの要素も親の から取得した値を上書きできます。指定されていない場合、デフォルトのFlowDirectionはLeftToRightです。

通常、このプロパティは、ウィンドウのルート要素/フレームに対して1回設定する必要があります。

ただし、FontIconImageのような要素は自動的にミラーリングされません。 FontIconはMirroredWhenRightToLeftプロパティを持っています

あなたは が流れ方向がrightToLeftのときにミラーリング表示されるグリフを持つようにMirroredWhenRightToLeftプロパティを設定することができます。あなたは一般的に 使用FontIconは、コントロールテンプレートの一部 としてのアイコンを表示するために使用され、アイコンがコントロール画像用の

の 残りの部分と一緒にミラーリングする必要があり、このプロパティには、反転する必要があります変換による画像。

編集:

あなたはメインフレーム/ページを作成Applicationクラスにプロパティを設定することができます。あなたが背後にあるコードを使用したくない場合は

// Part of the App.xaml.cs in default UWP project template: 

protected override void OnLaunched(LaunchActivatedEventArgs e) { 

#if DEBUG 
if (System.Diagnostics.Debugger.IsAttached) { 
    this.DebugSettings.EnableFrameRateCounter = true; 
} 
#endif 

Frame rootFrame = Window.Current.Content as Frame; 

// Do not repeat app initialization when the Window already has content, 
// just ensure that the window is active 
if (rootFrame == null) { 
// Create a Frame to act as the navigation context and navigate to the first page 
    rootFrame = new Frame(); 

    rootFrame.NavigationFailed += OnNavigationFailed; 

    if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { 
     //TODO: Load state from previously suspended application 
    } 

    //********************** 
    // Set flow direction 
    // ********************* 
    if (System.Globalization.CultureInfo.CurrentCulture.TextInfo.IsRightToLeft) { 
     rootFrame.FlowDirection = FlowDirection.RightToLeft; 
    } 

    // Place the frame in the current Window 
    Window.Current.Content = rootFrame; 

    } 
    ... 
    ... 

(と思います)このシナリオのためにそれを使用してOK、あなたはIValueConverter(推奨しない)を実装することができます

public class RightToLeftConverter : IValueConverter { 
    public object Convert(object value, Type targetType, 
     object parameter, string language) { 
        if (System.Globalization.CultureInfo.CurrentCulture.TextInfo.IsRightToLeft) { 
      return FlowDirection.RightToLeft; 
     } 
     return FlowDirection.LeftToRight; 
    } 

    public object ConvertBack(object value, Type targetType, 
     object parameter, string language) 
    { 
     throw new NotImplementedException(); 
    } 
} 

をし、XAMLでそれを使用します。

<Page 
    ... 
    ... 
    FlowDirection="{Binding Converter={StaticResource RightToLeftConverter}}"> 
+0

ありがとうございます! XAMLの現在の文化だけにバインドする方法があれば、それは後ろにコード化されていませんか? –

+1

@JuniorD答えを更新しました。 –

関連する問題