using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace MuchInfo.Chart.WPF.Helpers
{
public class MenuItemHelper
{
///
/// Creates the menu item.
///
/// The title.
/// The image.
/// The onclick.
/// MenuItem.
public static MenuItem CreateMenuItem(string title, BitmapImage image, EventHandler onclick)
{
var item = new MenuItem()
{
Icon = new Image() { Source = image },
Header = new TextBlock()
{
MinWidth = 60,
Padding = new Thickness(8, 4, 12, 4),
Text = title
}
};
item.PreviewMouseLeftButtonDown += (s, e) =>
{
if (onclick != null)
{
onclick.Invoke(s, e);
}
e.Handled = true;
};
return item;
}
}
}