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.

DataBinding a ContextMenu in Windows Phone

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

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...