views:

34

answers:

1

Code:

<Button Style="{StaticResource HPForegroundStyle}" IsTabStop="False"                 
        Command="{Binding ForegroundPhoneCommand}"  Click="Button_Click">
                    <Button.ContextMenu>                   
                        <ContextMenu ItemsSource="{Binding OptionsMenuItemList}"                            ItemContainerStyle="{StaticResource ContextMenuItemStyle}" 
                                     IsOpen="{Binding IsMenuOpen}"                                        
                                     PlacementTarget="{Binding RelativeSourc={RelativeSource AncestorType={x:Type Button}}}">
                        </ContextMenu>
                    </Button.ContextMenu>
    </Button>

i am using MVVM pattern. In ViewModel i have a property 'IsMenuOpen' which controls context menu open close .Problem is that i'm able to disable right click and not able to show context menu on left click.

A: 

If you want to bind a menu to a property, consider the Popup control. It has similar functionality to the context menu but is not bound to a particular mouse button...

<Popup IsVisible = {Binding IsMenuOpen} >
    <!-- Fill in what you need here -->
</Popup>
TerrorAustralis