blob: faf9cb810eb5ee016ee0adb801a852e22a6dee6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
using System.Windows;
using System.Windows.Controls;
using Microsoft.Phone.Controls;
using WMenuItem = Microsoft.Phone.Controls.MenuItem;
using WApplication = System.Windows.Application;
namespace Xamarin.Forms.Platform.WinPhone
{
public sealed class CustomContextMenu : ContextMenu
{
protected override DependencyObject GetContainerForItemOverride()
{
var item = new WMenuItem();
item.SetBinding(HeaderedItemsControl.HeaderProperty, new System.Windows.Data.Binding("Text") { Converter = (System.Windows.Data.IValueConverter)WApplication.Current.Resources["LowerConverter"] });
item.Click += (sender, args) =>
{
IsOpen = false;
var menuItem = item.DataContext as MenuItem;
if (menuItem != null)
((IMenuItemController)menuItem).Activate();
};
return item;
}
}
}
|