0
我有一個TextBox綁定到我的ViewModel。 TextBox的TextWrapping屬性綁定到我的View Model上名爲DocViewerWrapText的屬性。這是我的財產 - 忽略關於打開和關閉scollbar的位。Silverlight - 綁定到枚舉屬性
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中綁定枚舉的正確方法嗎?
感謝,
斯科特