3
我有一個帶狀組合框(MS絲帶開源項目,.NET 4.0),這是綁定到我的視圖模型的屬性這樣的數據:RibbonComboBox不更新的SelectedValue
XAML:
<ribbon:RibbonComboBox SelectionBoxWidth="130" Margin="3,0">
<ribbon:RibbonGallery
SelectedValue="{Binding Source={StaticResource ViewModel},
Path=Document, Converter={StaticResource DocumentToDocumentNameConverter}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<ribbon:RibbonGalleryCategory
ItemsSource="{Binding Source={StaticResource ViewModel},
Path=Documents, Converter={StaticResource DocumentToDocumentNamesConverter}}">
</ribbon:RibbonGalleryCategory>
</ribbon:RibbonGallery>
</ribbon:RibbonComboBox>
視圖模型:
public ViewModel {
#region Fields
private TestDocument _Document;
#endregion
#region Properties
public TestDocument Document
{
get
{
return ModelClass.SelectedDocument;
}
set
{
if (value != null && value != _Document)
{
_Document = value;
OnPropertyChanged("Document");
}
}
}
#endregion
}
如果我選擇在C另一個值這工作好, omboBox輸入轉換器並顯示值 。
但如果我設置屬性在視圖模型這樣
Document = new TestDocument("DocumentName");
所選擇的組合框不顯示姓名。
你有什麼建議嗎?我甚至試圖綁定SelectedItem而不是SelectedValue,但這並不能解決問題。我忘了什麼嗎?
這是問題。謝謝,我知道我已經忘記了一些東西。 –