如何在wpf中动态添加带url的菜单项 [英] How to add menu item with url dynamically in wpf

查看:109
本文介绍了如何在wpf中动态添加带url的菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







我有菜单控件我必须使用菜单控件来触发不同的页面,从数据库绑定的菜单项可以指导我或发送片段

解决方案

你可以做的是在XAML中创建一个菜单并命名为你可以参考的东西。在后面的代码中,您可以根据数据库记录创建 MenuItem 。并设置标记以标识 MenuItem 是什么 - 让我们假设您为其分配记录的ID。处理点击它的事件并使用 sender 对象获取存储在其中的ID并将其转换为菜单项。然后使用适当的案例来浏览页面等。



有关 MenuItem 的更多信息,请查看此处。 [ ^

Hi,


I have menu control i have to nagivate different pages using menu control, menu items bound from database can u guide me or send snippets

解决方案

What you can do is create a Menu in XAML and name it something which you can refer to. In the code behind, you can create MenuItem as per your database records. And set the tag to identify what the MenuItem is - lets suppose you assign ID of the record to it. Handle the Click event of it and get the ID which is stored in it using the sender object and casting it into MenuItem. Then use the proper cases for which page to navigate etc.

For more information on MenuItem, check it out here.[^]


这篇关于如何在wpf中动态添加带url的菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆