私は自分のViewModelにバインドされているTextBoxを持っています。 TextBoxのTextWrappingプロパティは、DocViewerWrapTextというビューモデルのプロパティにバインドされています。ここに私の財産があります - スカルバのオン/オフについてのビットを無視してください。Silverlight - Enumプロパティへのバインド
public string DocViewerWrapText
{
get { return _docViewerWrapText; }
set
{
_docViewerWrapText = value;
if (_docViewerWrapText == "Wrap")
ShowDocViewerHorizontalScrollBar = "Disabled";
else ShowDocViewerHorizontalScrollBar = "Auto";
NotifyPropertyChanged("ShowDocViewerHorizontalScrollBar");
NotifyPropertyChanged("DocViewerWrapText");
}
}
このコードは実際にはうまく動作しますが、以下のように、それは最初のチャンス例外がスローされます。
System.Windows.Data Error: 'MS.Internal.Data.DynamicValueConverter' converter failed to convert value 'NoWrap' (type 'System.String'); BindingExpression: Path='DocViewerWrapText' DataItem='UnityEca.ViewModels.HomeViewModel' (HashCode=41697354); target element is 'Telerik.Windows.Controls.RadToggleButton' (Name='docViewerWrapText'); target property is 'IsChecked' (type 'System.Nullable`1[System.Boolean]').. System.FormatException: String was not recognized as a valid Boolean.
私はブールに自分の財産を変換しようとしましたが、私はエラーの同じタイプを取得します。また、TextWrapping列挙の実際の列挙を見てきました。値は1と2なので、どうにかここにブール値を使う方法はわかりません。
XAMLのような列挙型にバインドする正しい方法を教えてもらえますか?
おかげで、
-Scott