1

I have a boolean property namely "messageinlistbox". I am trying to bind this property with the context menu. It is not working.

  1. This is the following code which i am trying to implement.

    ContextMenu Name="contextMenu" StaysOpen="true" Background="WhiteSmoke" IsEnabled="{Binding Path=messageinlistbox}" DataContext="{Binding Path=PlacementTarget, RelativeSource={RelativeSource Self}}">

  2. When i am trying to implement the following code it is working fine.

    ContextMenu Name="contextMenu" StaysOpen="true" Background="WhiteSmoke" IsEnabled="false" DataContext="{Binding Path=PlacementTarget, RelativeSource={RelativeSource Self}}">

Since my requirement is that the context menu should be dynamically enabled and disabled with respect to the boolean property "messageinlistbox" So, I cant use the second scenario.

IS it the right way I am doing binding or any other correct way to make the context menu enable and disable dynamically?

itzmebibin
  • 9,199
  • 8
  • 48
  • 62
  • Please refer this post : http://stackoverflow.com/questions/7781932/wpf-usercontrol-context-menu-visibility-binding – lerner1225 Apr 20 '15 at 09:05
  • The referred post didn't solved my purpose. Do you have any other solution ? – Beginner_coder Apr 23 '15 at 05:01
  • If messageinlistbox is false -> You want to show context menu with all options disabled or you don't want to show the menu at all? – lerner1225 Apr 23 '15 at 07:46
  • I want the option to show as disabled . Its similar to to copy and paste . when nothing is copied and the user right click the mouse then the paste option is shown disabled or you can say freezed – Beginner_coder Apr 23 '15 at 10:24

0 Answers0