Frage

I have a WPF application where I was suppose to add an "empty" item when nothing is there in the menu.

I have implemented it but I want to know how to make that empty item as non select-able whenever mouse over is there while for other menu it should work normally.

Kindly suggest.

enter image description here

War es hilfreich?

Lösung

Try set IsEnabled for MenuItem to false:

Gets or sets a value indicating whether this element is enabled in the user interface.

Example:

<MenuItem Header="_Favorites">
    <MenuItem Header="Empty" 
              IsEnabled="False" />

    <MenuItem Header="AnotherItem" 
              IsEnabled="True" />
    ...
</MenuItem>

Also you can try set IsHitTestVisible for MenuItem to false:

Gets or sets a value that declares whether this element can possibly be returned as a hit test result from some portion of its rendered content.

Example:

<MenuItem Header="_Favorites">
    <MenuItem Header="Empty" 
              IsHitTestVisible="False" />
    ...
</MenuItem>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top