
Hello,
I have a ribbon drop down that contains items that the user can delete/edit. I would like to have a context menu that is available on each item of the drop down with "delete" and "edit" menu items. The problem is that the menu items are not highlighting when the cursor is placed over the context menu's items.
Below is the xaml and codebehind that is used to reproduce the issue. Any ideas?
I have a ribbon drop down that contains items that the user can delete/edit. I would like to have a context menu that is available on each item of the drop down with "delete" and "edit" menu items. The problem is that the menu items are not highlighting when the cursor is placed over the context menu's items.
Below is the xaml and codebehind that is used to reproduce the issue. Any ideas?
<ribbon:RibbonWindow x:Class="RibbonDropdownRightClickMenu.Window1"
xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" >
<DockPanel>
<ribbon:Ribbon DockPanel.Dock="Top">
<ribbon:Tab Label="Home">
<ribbon:Group Label="Test">
<ribbon:PopupButton Label="Drop Down" >
<StackPanel>
<ribbon:Menu>
<ribbon:Separator Label="Menu Header" />
</ribbon:Menu>
<ribbon:Menu ItemsSource="{Binding ItemsInMenu}">
<ribbon:Menu.ItemTemplate>
<DataTemplate DataType="ribbon:SimpleDataItem">
<ribbon:Button Context="MenuItem" Label="{Binding Name}" >
<ribbon:Button.ContextMenu>
<ribbon:ContextMenu>
<ribbon:Button Context="MenuItem" Label="Delete" />
<ribbon:Button Context="MenuItem" Label="Edit" />
</ribbon:ContextMenu>
</ribbon:Button.ContextMenu>
</ribbon:Button>
</DataTemplate>
</ribbon:Menu.ItemTemplate>
</ribbon:Menu>
</StackPanel>
</ribbon:PopupButton>
</ribbon:Group>
</ribbon:Tab>
</ribbon:Ribbon>
</DockPanel>
</ribbon:RibbonWindow>
using System.Collections.ObjectModel;
using System.ComponentModel;
using ActiproSoftware.Windows.Controls.Ribbon;
namespace RibbonDropdownRightClickMenu
{
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void NotifyPropertyChanged(string propertyName)
{
OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
}
protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, args);
}
}
}
public class MenuItemViewModel : ViewModelBase
{
private string _name;
public string Name
{
get { return _name; }
set
{
if (_name != value)
{
_name = value;
NotifyPropertyChanged("Name");
}
}
}
}
public class RibbonViewModel
{
ObservableCollection<MenuItemViewModel> _itemsInMenu = new ObservableCollection<MenuItemViewModel>();
public ObservableCollection<MenuItemViewModel> ItemsInMenu { get { return _itemsInMenu; } }
public RibbonViewModel()
{
_itemsInMenu.Add(new MenuItemViewModel() { Name = "First" });
_itemsInMenu.Add(new MenuItemViewModel() { Name = "First" });
_itemsInMenu.Add(new MenuItemViewModel() { Name = "First" });
_itemsInMenu.Add(new MenuItemViewModel() { Name = "First" });
}
}
public partial class Window1 : RibbonWindow
{
public Window1()
{
DataContext = new RibbonViewModel();
InitializeComponent();
}
}
}