jharr100
jharr100

Reputation: 1469

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

Upvotes: 3

Views: 1338

Answers (1)

Dylan Meador
Dylan Meador

Reputation: 2401

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" />

Upvotes: 2

Related Questions