如何在左侧执行带徽标的上下文菜单

时间:2022-11-20 07:55:08

I've looking for 4 hours how can I do a context menu with logo. I mean something which looks like daemon tools context menu.

我正在寻找4小时,如何进行带徽标的上下文菜单。我的意思是看起来像守护进程工具上下文菜单。

For these who dont know how it looks like: 如何在左侧执行带徽标的上下文菜单

对于那些不知道它是什么样子的人:

Is there any option to do it in simple way in XAML?

有没有选择在XAML中以简单的方式完成它?

1 个解决方案

#1


5  

You will have to adjust ContextMenu's control template.

您必须调整ContextMenu的控件模板。

Just copy the whole thing and and wrap this StackPanel in Grid or DockPanel to which you add the image:

只需复制整个内容,然后将此StackPanel包装在Grid或DockPanel中,并将图像添加到其中:

<StackPanel ClipToBounds="True" Orientation="Horizontal" IsItemsHost="True" />

Once you understand and learn not to fear control templates, they are really not a big deal. No C# necessary, all is pure XAML.

一旦你理解并学会不要害怕控制模板,它们真的不是什么大问题。没有必要的C#,都是纯XAML。

Brief tutorial.

#1


5  

You will have to adjust ContextMenu's control template.

您必须调整ContextMenu的控件模板。

Just copy the whole thing and and wrap this StackPanel in Grid or DockPanel to which you add the image:

只需复制整个内容,然后将此StackPanel包装在Grid或DockPanel中,并将图像添加到其中:

<StackPanel ClipToBounds="True" Orientation="Horizontal" IsItemsHost="True" />

Once you understand and learn not to fear control templates, they are really not a big deal. No C# necessary, all is pure XAML.

一旦你理解并学会不要害怕控制模板,它们真的不是什么大问题。没有必要的C#,都是纯XAML。

Brief tutorial.