如何将数据库中的列表绑定到 RibbonComboBox 中?

发布于 2024-12-03 01:05:43 字数 558 浏览 4 评论 0原文

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

我认为我需要将 RibbonComboBoxRibbonGalleryCategory 一起使用,并以某种方式绑定 RibbonGalleryItem 来显示数据库的结果。

我的数据库函数的代码如下所示:

    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;
    }

非常感谢这里的任何帮助!

I have function that return list of strings from database. I want to show those results in wpf ribbon menu.

I think that I need to use RibbonComboBox with RibbonGalleryCategory and bind RibbonGalleryItem somehow to show resulats from db.

Code of my db function looks like that:

    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;
    }

Any help here much appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瑕疵 2024-12-10 01:05:43

这应该适用于您的情况:

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

This should work in your case:

<ribbon:RibbonComboBox IsEditable="True">
   <ribbon:RibbonGallery>
       <ribbon:RibbonGalleryCategory ItemsSource="{Binding}" Name="seanceList"/>
    </ribbon:RibbonGallery>
</ribbon:RibbonComboBox>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文