Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF ContextMenu
    primarykey
    data
    text
    <p>I am using mvvm in a wpf app. I have a ContextMenu inside of a listview and when I right click a listviewitem i want a contextmenu to display a list of Contacts. </p> <p>The following just gives me a contextmenu with no content. Can anyone tell me what I'm doing wrong?</p> <pre><code>&lt;ListView Grid.Row="3" ItemsSource="{Binding Path=Phones}" SelectedItem="{Binding Phones.SelectedItem}" Height="100"&gt; &lt;ListView.ItemContainerStyle&gt; &lt;Style TargetType="{x:Type ListViewItem}"&gt; &lt;Setter Property="ContextMenu" Value="{StaticResource ContactMenu}"/&gt; &lt;/Style&gt; &lt;/ListView.ItemContainerStyle&gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridViewColumn Header="Phone" DisplayMemberBinding="{Binding Path=PhoneNumber, StringFormat=(000) 000-0000}"/&gt; &lt;GridViewColumn Header="Type" DisplayMemberBinding="{Binding Path=PhoneType.Type}"/&gt; &lt;GridViewColumn Header="Contacts" DisplayMemberBinding="{Binding Path=Contacts.Count}"/&gt; &lt;GridViewColumn Header="Notes" DisplayMemberBinding="{Binding Path= Notes.Count}"/&gt; &lt;GridViewColumn Header="Priority" DisplayMemberBinding="{Binding Path=Priority}"/&gt; &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;/ListView&gt; &lt;UserControl.Resources&gt; &lt;Style TargetType="{x:Type ListViewItem}"&gt; &lt;Setter Property="Background" Value="{Binding SourceType, Converter={StaticResource SourceGroupConverter}}"/&gt; &lt;/Style&gt; &lt;ContextMenu x:Key="ContactMenu" ItemsSource="{Binding Contacts}" &gt; &lt;ContextMenu.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;MenuItem Header="{Binding Path=FirstName}"/&gt; &lt;/DataTemplate&gt; &lt;/ContextMenu&gt; &lt;/UserControl.Resources&gt; </code></pre> <p>UPDATE:</p> <p>I figured it out, I had a specialized collection that caused the binding path to be incorrect.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload