Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
It does not work off MenuItem in ContextMenu.

Bind it to the ListView. If an element in ListVIew not selected, IsEnabled a MenuItem should be able to false.

<Window.Resources>
     <ContextMenu x:Key="CategoryiesTaskMenu">
         <MenuItem Header="Add Category"/>
            <MenuItem Header="Edit Category">
                 <MenuItem.Style>
                    <Style TargetType="{x:Type MenuItem}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ElementName=listView, Path=SelectedIndex}" Value="-1">
                                <Setter Property="IsEnabled" Value="False"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </MenuItem.Style>
            </MenuItem>
      </ContextMenu>
</Window.Resources>

<ListView Name="listViewTask" ContextMenu="{DynamicResource CategoryiesTaskMenu}">
Posted

1 solution

Well, your element name is ListViewTask, and your trigger is using listView.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900