0

I am developing a custom control for WinRT. I have a property with type CultureInfo. When I try to set this property in XAML, it shows following error.(But it shows possible values in intellisense.)

Cannot assign text value 'af-ZA' into property 'Culture' of type 'CultureInfo'

What is the correct way to set this property from XAML?

Thanks,

4

1 に答える 1

2

名前のないコントロールの Culture プロパティは、カルチャ名ではなくCultureInfoオブジェクトを受け取るようです。CultureInfo オブジェクトを作成し、おそらくコード ビハインドでプロパティに割り当てます。

CultureInfoConverterクラスがWinRT で使用できない可能性があるようです。WinRT System.ComponentModel 名前空間にはありません。実際、TypeConverter クラスは存在しませんが ( System.ComponentModel.TypeConverter の WinRT 置換を参照)、IValueConverterは存在するため、独自のクラスを作成できます。コンバーターの使用方法については、「XAML でコンバーターを挿入する方法」を参照してください。

于 2012-09-30T13:28:20.130 に答える