Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So after reading Meleak's answer and finding out that you can have a style within a style via resources what probably comes closest to doing this with a setter is an embedded style to access the icon's opacity. Here i assume the icon to be an image so i use that as the target type, the complete style hence looks like this:</p> <pre><code>&lt;Style x:Key="MenuItemMouseOverStyle" TargetType="MenuItem"&gt; &lt;Style.Resources&gt; &lt;Style TargetType="Image"&gt; &lt;Setter Property="Opacity" Value="0.5"/&gt; &lt;/Style&gt; &lt;/Style.Resources&gt; &lt;Style.Triggers&gt; &lt;EventTrigger RoutedEvent="MouseEnter"&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Icon.Opacity"&gt; &lt;EasingDoubleKeyFrame KeyTime="0" Value="0.5"/&gt; &lt;EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/EventTrigger&gt; &lt;EventTrigger RoutedEvent="MouseLeave"&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Icon.Opacity"&gt; &lt;EasingDoubleKeyFrame KeyTime="0" Value="1"/&gt; &lt;EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0.5"/&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/EventTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; </code></pre> <p>The only problem with this is that it does not actually set the <code>Icon.Opacity</code> but the opacity of all images that may occur within the MenuItem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload