2016-07-15 3 views
0

ラベルの内容が "seg"(ブラジルのポルトガル語の月曜日)になるようにカルチャーを正しく設定する方法はありますか?ラベルの日付形式の文化を設定する

TextBlock用のConverterCultureを設定すると、テキストバインディングはpt-BRに変更されますが、LabelCaptureのLabelBinding用の設定は変更されません。以下のXAML。

<Window x:Class="CurrentCulture.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:sys="clr-namespace:System;assembly=mscorlib" 
     Title="MainWindow" Height="350" Width="525"> 
    <Grid> 
     <Grid.Resources> 
      <sys:DateTime x:Key="Td:Mon">2007-1-1</sys:DateTime> 
     </Grid.Resources> 
     <StackPanel> 
      <Label Content="{Binding Source={StaticResource Td:Mon}, ConverterCulture=pt-BR}" ContentStringFormat="{}{0:ddd}" /> 
      <TextBlock Text="{Binding Source={StaticResource Td:Mon}, ConverterCulture=pt-BR,StringFormat={}{0:ddd}}" /> 
     </StackPanel> 
    </Grid> 
</Window> 

答えて

2

のTextBlockのTextプロパティがstring型を持つため、コンバータは、ブラジルのスタイルを適用する文字列に日時を変換するために使用されます。

ラベルのContentプロパティは、タイプobjectです。 DateTimeはオブジェクトなので、コンバータは使用されないため、ConverterCultureは無視されます。 Stringへの変換は、デフォルト言語を使用してContentStringFormatによって行われます。

希望する結果を得るには、ラベルにLanguage="pt-BR"属性を追加します。

関連する問題