DataBinding a ContextMenu in Windows Phone

In this blog post , i will demonstrate how one can populate the Context menu via Data Binding .

The context menu like other Data controls too have an ItemSource property .

In the below sample source code , i have used the List of string and binded it to the context menu and the context menu is set for the text box .

ContextMenu PopUpMenu = new ContextMenu();
List MenuData = new List();
MenuData.Add("Windows Phone");
MenuData.Add("Android");
MenuData.Add("iPhone");
MenuData.Add("BlackBerry");
PopUpMenu.ItemsSource = MenuData;
ContextMenuService.SetContextMenu(this.textBox1, PopUpMenu);
DataBinding a ContextMenu in Windows Phone

DataBinding a ContextMenu in Windows Phone

 

 

Leave a Reply