문제

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

도움이 되었습니까?

해결책

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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top