2011-09-05 21 views
2

我有從數據庫返回字符串列表的函數。我想在wpf功能區菜單中顯示這些結果。如何將數據庫中的列表綁定到RibbonComboBox?

我認爲我需要使用RibbonComboBoxRibbonGalleryCategory並以某種方式綁定RibbonGalleryItem以顯示來自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; 
    } 

這裏任何幫助,非常感謝!

+0

卡桑德拉看看這個,希望可以幫助:的http://stackoverflow.com/questions/6700696/bind-ribboncombobox-selectionboxitem –

+2

可能重複[如何數據綁定RibbonComboBox?](http://stackoverflow.com/questions/5237319/how-to-data-binding-ribboncombobox) –

+0

感謝您的幫助!是的,你是對的 - 它看起來像是重複的。這個問題的答案也適用於我。 – Marta

回答

0

這應該工作你的情況:

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