1 回答
TA贡献1853条经验 获得超9个赞
您正在绑定SelectedValue到一个集合。您不需要自定义集合。只需添加ObservableCollection到您的视图模型并移动所选项目上的项目已更改:
查看型号:
private void OnSelectedMostRecentFileChanged()
{
// Move the selected item to the front of the list
this.MostRecentFiles.Move(this.MostRecentFiles.IndexOf(this.SelectedRecentFile), 0);
}
private string _selectedRecentFile;
public string SelectedRecentFile
{
get { return _selectedRecentFile; }
set
{
_selectedRecentFile= value;
OnSelectedMostRecentFileChanged();
OnPropertyChanged(nameof(SelectedRecentFile));
}
}
private ObservableCollection<string> _mostRecentFiles = new ObservableCollection<string>();
public ObservableCollection<string> MostRecentFiles
{
get { return _mostRecentFiles; }
set
{
_mostRecentFiles = value;
OnPropertyChanged(nameof(MostRecentFiles));
}
}
看法:
<ribbon:RibbonApplicationMenu.AuxiliaryPaneContent>
<ribbon:RibbonGallery Name="RecentDocuments" CanUserFilter="False"
SelectedItem="{Binding SelectedRecentFile}">
<ribbon:RibbonGalleryCategory Header="Recent Documents"
ItemsSource="{Binding MostRecentFiles}">
</ribbon:RibbonGalleryCategory>
</ribbon:RibbonGallery>
</ribbon:RibbonApplicationMenu.AuxiliaryPaneContent>
- 1 回答
- 0 关注
- 146 浏览
添加回答
举报