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 will learn about sync provider notifications in Windows 11 and how to disable or enable it...
In this tutorial, let’s learn how to enable or disable the startup sound in Windows 11. By default, when Windows...
The CameraCaptureTask allows the Windows Phone 7 App to launch the Camera Application . This will be useful when the...