如何在WPF中突出显示MouseOver上的菜单项

时间:2018-06-15 14:18:45

标签: wpf

我有一个菜单项,当我把鼠标放在它上面时,它不会改变它的背景。

#include <stdio.h>
#include <stdlib.h>

int max_fil, count;
typedef struct listDef{
   float *values;
   int id;
   int nElements;

} ListSt;



ListSt ListSt_init(ListSt *m, int i, int s){
    m[i].values = (float *)malloc(sizeof(float)*s);
    printf("-----------\n");
    printf("CREATE Element n.%i :\n\n", i);
    for(int j=0;j<s;j++){
        m[i].id = i;
        m[i].nElements = s;
        m[i].values[j] = 0.0000 + count*(0.1);
        printf("m[%i][%i]  ID: %i  TotalElements: %i  Value[%i]: %f\n", i, j, m[i].id, m[i].nElements, j, m[i].values[j]);
        count++;
    }

    return m[i];
}


int main()
{
    max_fil = 100; /* Max 'ListSt' elements addresses to be created */
    count = 0; /* Just a global counter for each 'values' */
    int sizes[] = {4,8,4}; /* The sizes of each 4 elements to be created */
    ListSt *m = NULL;
    m = (ListSt *)malloc(sizeof (ListSt) * max_fil); /* Assign a memory address for accesing 'm' (ListSt) */

    /* Lets create three lists */
    m[0] = ListSt_init(m, 0, sizes[0]);
    m[1] = ListSt_init(m, 1, sizes[1]);
    m[2] = ListSt_init(m, 2, sizes[2]);

    printf("\n-----------\n");
    printf("PRINT RESULT :\n");
    printf("-----------\n\n");
    /* Now we show the elements.... */
    for(int i=0;i<3;i++){
        printf("RESULT Element n.%i :\n\n", i);
        for(int j=0;j<sizes[i];j++){
            printf("m[%i][%i]  ID: %i  TotalElements: %i  Value[%i]: %f\n", i, j, m[i].id, m[i].nElements, j, m[i].values[j]);
        }
    }
    free(m);
    return 0;
}

如果有任何错误,请编辑此内容

1 个答案:

答案 0 :(得分:0)

设置背景=&#34;#FF101315&#34; DockPanel上的优先级高于触发器的设置器。改为将其移至样式:

<DockPanel HorizontalAlignment="Left" Height="40" Width="250" Margin="-1,-1,0,0">

<!-- Skipped for readability -->

            <Style TargetType="DockPanel">
                <Setter Property="Background" Value="#FF101315"/>
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Background" Value="#FF1A1D1F" />
                        <Setter Property="Opacity" Value="0.5" />
                        <Setter Property="Cursor" Value="Hand" />
                    </Trigger>
                </Style.Triggers>
            </Style>