如何将列表从数据库绑定到RibbonComboBox

本文关键字:绑定 RibbonComboBox 数据库 列表 | 更新日期: 2023-09-27 18:07:42

我有从数据库返回字符串列表的函数。我想在wpf功能区菜单中显示这些结果。

我认为我需要使用RibbonComboBoxRibbonGalleryCategory并以某种方式绑定RibbonGalleryItem来显示db的结果。

我的db函数代码如下:

    public List<String> GetSeanceListName()
    {
        List<String> seanceList = new List<String>();
        seanceList = (from s in Db.Seance
                          where s.Date >= DateTime.Today
                      select s.Name).ToList();
        return seanceList;
    }

任何帮助在这里非常感激!

如何将列表从数据库绑定到RibbonComboBox

这应该在你的情况下工作:

<ribbon:RibbonComboBox IsEditable="True">
   <ribbon:RibbonGallery>
       <ribbon:RibbonGalleryCategory ItemsSource="{Binding}" Name="seanceList"/>
    </ribbon:RibbonGallery>
</ribbon:RibbonComboBox>