2012-02-03 15 views
0

私はPrism 4.0を使って書かれたアプリケーションを持っています。 ViewModelのプロパティにバインドするさまざまなコントロールを持つビューがたくさんあります(私のアプリケーションにはモデルはありません)。これらのコントロールの一部は、日時と小数値を視覚化します。いくつかの場所では、文字列表現は正しい書式を持ちますが、一部の場所では表示されません。しかし、文字列のプロパティとして10進数と日時のプロパティを表現し、基になる値のToString()メソッドを呼び出すと、その形式は正しいでしょう。したがって、私のViewModelスレッドのCurrentThread.CurrentCultureは正しいです。しかし、データバインダーやプリズムなどのコードでは、datetimeとdecimalの値を文字列のスレッドカルチャに変換するのは間違っているようですが、現在のカルチャを使用していない可能性もあります。私のデバッグスキルがカーテンの後ろに行くにはまだ十分ではありませんが、私は魔法が(スタックトレース)ここで起こっていることだと思う:プリズムローカリゼーションの問題:正しい番号と日付時刻の形式が使用されていません

[Native to Managed Transition] 
    PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.GetValue(object item, int level) 
    PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.RawValue(int k) 
    PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.RawValue()  
    PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.RawValue() 
    PresentationFramework.dll!System.Windows.Data.BindingExpression.TransferValue(object newValue, bool isASubPropertyChange) 
    PresentationFramework.dll!System.Windows.Data.BindingExpression.ScheduleTransfer(bool isASubPropertyChange) 
    PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.NewValueAvailable(bool dependencySourcesChanged, bool initialValue, bool isASubPropertyChange) 
    PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(int k, System.ComponentModel.ICollectionView collectionView, object newValue, bool isASubPropertyChange) 
    PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(object o, string propName) 

どこでも正しい番号と日時のフォーマットを使用してWPF &プリズムを強制的にどのように任意のアイデアは?

+1

[WPFバインディングは間違ったCurrentCultureを使用しています](http://connect.microsoft.com/VisualStudio/feedback/details/442569/wpf-binding-uses-the-wrong-currentculture-by- – Lukazoid

答えて

0

スタートアップコードに次のコード行を配置しても問題が解決することがあります。

FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); 

これは、WPFは、現在のカルチャに制御し、すべてのためにLanguagePropertyを設定します。

+0

ええ、それは実際にコメントであなたのリンクから投稿を読んだ後に修正した方法です。ありがとう。 –

関連する問題