Search code examples
c#.netwpfxamlribbon

How to bind list from database into RibbonComboBox?


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!


Solution

  • This should work in your case:

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