Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Context Menu Binding in C# WPF

When you set an observable collection as the item source of a context menu it lists the type of the each item...i would like to bind the name field of those items in the collection to the header...I cant seem to figure out how to

like image 833
jharr100 Avatar asked Dec 03 '25 07:12

jharr100


1 Answers

Use DisplayMemberPath and put the name of the property on your item. Or you could use the ItemTemplate property.

Example:

<ContextMenu ItemsSource="{Binding YourCollection}"
             DisplayMemberPath="Name" />
like image 193
Dylan Meador Avatar answered Dec 05 '25 22:12

Dylan Meador