Hello
I cannot bind ApplicationMenu items to collection in code-behind. Here is simplified example of what I try to do
xaml:Code-behind:
After executing the code, Application menu of ribbon control will be empty. I want it to contain 5 items: "Hello1", ..., "Hello5".
I guess the reason is that ApplicationMenu doesn't host ribbon:Button directly, but wraps it with ribbon:MenuItem. How to write it in ApplicationMenu's ItemTemplate definition to make binding work?
Thanks in advise
I cannot bind ApplicationMenu items to collection in code-behind. Here is simplified example of what I try to do
xaml:
<ribbon:Ribbon Grid.Row="0" x:Name="Ribbon">
<ribbon:Ribbon.ApplicationMenu>
<ribbon:ApplicationMenu Name="AppMenu">
<ribbon:ApplicationMenu.ItemTemplate>
<DataTemplate>
<ribbon:Button Label="{Binding Label}"/>
</DataTemplate>
</ribbon:ApplicationMenu.ItemTemplate>
</ribbon:ApplicationMenu>
</ribbon:Ribbon.ApplicationMenu>
</ribbon:Ribbon>
public MainRibbonWindow()
{
InitializeComponent();
ObservableCollection<RibbonMenuItem> items = new ObservableCollection<RibbonMenuItem>();
items.Add(new RibbonMenuItem("Hello1"));
items.Add(new RibbonMenuItem("Hello2"));
items.Add(new RibbonMenuItem("Hello3"));
items.Add(new RibbonMenuItem("Hello4"));
items.Add(new RibbonMenuItem("Hello5"));
AppMenu.ItemsSource = items;
}
public class RibbonMenuItem
{
public RibbonMenuItem(String label)
{
_label = label;
}
private String _label;
public String Label
{
get
{
return _label;
}
}
}
I guess the reason is that ApplicationMenu doesn't host ribbon:Button directly, but wraps it with ribbon:MenuItem. How to write it in ApplicationMenu's ItemTemplate definition to make binding work?
Thanks in advise