| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media.Imaging;
- namespace MuchInfo.Chart.WPF.Helpers
- {
- public class MenuItemHelper
- {
- /// <summary>
- /// Creates the menu item.
- /// </summary>
- /// <param name="title">The title.</param>
- /// <param name="image">The image.</param>
- /// <param name="onclick">The onclick.</param>
- /// <returns>MenuItem.</returns>
- 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;
- }
- }
- }
|