Here is xaml:
<r:RibbonWindow x:Class="WpfApplication1.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
xmlns:local="clr-namespace:WpfApplication1.ViewModel"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<DataTemplate DataType="{x:Type local:RibbonItem}">
<r:RibbonButton Label="{Binding Label}" SmallImageSource="{Binding ImageUri}" Command="{Binding Command}" />
</DataTemplate>
</Window.Resources>
<StackPanel>
<StackPanel.Resources>
<local:EmployeeViewModel x:Key="EmpoyeeViewModel"/>
</StackPanel.Resources>
<StackPanel.DataContext>
<Binding Source="{StaticResource EmpoyeeViewModel}"/>
</StackPanel.DataContext>
<r:Ribbon Name="ribbon" >
<r:Ribbon.ApplicationMenu>
<r:RibbonApplicationMenu
ItemsSource="{Binding MenuItems, Mode=OneWay}"
Margin="0, 5, 0, 0"
SmallImageSource="{Binding ImageUri}">
</r:RibbonApplicationMenu>
</r:Ribbon.ApplicationMenu>
<r:RibbonTab Header="Home">
<r:RibbonGroup x:Name="Clipboard" ItemsSource ="{Binding MenuItems, Mode=OneWay}" >
<r:RibbonGroup.ItemTemplate>
<DataTemplate>
<StackPanel>
<r:RibbonButton Label="{Binding Label}"
SmallImageSource="{Binding ImageUri}" Command="{Binding Command}"/>
</StackPanel>
</DataTemplate>
</r:RibbonGroup.ItemTemplate>
</r:RibbonGroup>
</r:RibbonTab>
</r:Ribbon>
</StackPanel>
</r:RibbonWindow>
View Model:
public class EmployeeViewModel : BaseModel
{
private RelayCommand _SaveCommand;
private RelayCommand _NewCommand;
public EmployeeViewModel()
{
LoadMenus();
}
public ICommand SaveCommand
{
get
{
return _SaveCommand ?? (_SaveCommand = new RelayCommand(param => Save(), param => CanSave));
}
}
public ICommand NewCommand
{
get
{
return _NewCommand ?? (_NewCommand = new RelayCommand(param => New())); ;
}
}
public bool CanSave
{
get { return true; }
}
private void Save() { }
private void New() { }
ObservableCollection<RibbonItem> _MenuItems;
public ObservableCollection<RibbonItem> MenuItems
{
get { return _MenuItems; }
}
private void LoadMenus()
{
_MenuItems = new ObservableCollection<RibbonItem>();
_MenuItems.Add(new RibbonItem("New", "new-icon.png", NewCommand));
_MenuItems.Add(new RibbonItem("Save", "save-icon.png", SaveCommand));
}
}
public class RibbonItem
{
public RibbonItem(string label, string imageUri, ICommand command)
{
Label = label;
ImageUri = imageUri;
Command = command;
}
public string Label { get; private set; }
public string ImageUri { get; private set; }
public ICommand Command { get; private set; }
}
Binding Errors:
System.Windows.Data Error: 40 : BindingExpression path error: 'ImageUri' property not found on 'object' ''EmployeeViewModel' (HashCode=41834681)'. BindingExpression:Path=ImageUri; DataItem='EmployeeViewModel' (HashCode=41834681); target element is 'RibbonApplicationMenu' (Name=''); target property is 'SmallImageSource' (type 'ImageSource')
System.Windows.Data Error: 40 : BindingExpression path error: 'IsDropDownOpen' property not found on 'object' ''RibbonContentPresenter' (Name='PART_ContentPresenter')'. BindingExpression:Path=IsDropDownOpen; DataItem='RibbonContentPresenter' (Name='PART_ContentPresenter'); target element is 'RibbonButton' (Name=''); target property is 'NoTarget' (type 'Object')
What is I am missing here?