问题描述
我创建了一个树视图,它是数据库中的类别和子类别的绑定。
我想在树视图的左侧显示一个图标(图像)。例如,在树形视图中,我有类别,例如amana工具作为父节点,路由器位作为amana工具的子节点。因此,在数据库中我有amana工具的图标以及路由器位的图标。现在,我只能在treeview中显示类别(amana工具)。但是,我需要左侧应显示相关类别的图标,然后显示类别名称(amana工具)。
注意:图标应该从数据库绑定,但它不应该是静态图标,因为我需要显示超过100个类别和数据库中存在的图标。
请帮帮我。
I have created a treeview, which is binding categories and subcategories from database.
I want to display an icon (image) on left side of the treeview. For example, in treeview I have categories such as amana tool as a parent node and the router bits as child node of amana tool. So, in database I have icon of amana tool as well as icon of router bits. Now, I am able to show categories (amana tool) only in treeview. But, I need that left side should show the icon of the related categories and then categories name(amana tool).
Note: The icon should bind from database but it should not be static icon because I need to show more than 100 categories and the icon existing in database.
Please help me out.
推荐答案
MenuItem Class:
public class MenuItem
{
public string Header { get; set; }
public string Url { get; set; }
public BitmapImage ImageSource { get; set; }
public List<menuitem> SubMenuItems { get; set; }
}
List <menuitem> MenuItems = new List<menuitem>();
MenuItems.Add(
new MenuItem()
{
Header = "Display Name",
Url = "NavigationUrl",
ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri("ur image url from database", UriKind.RelativeOrAbsolute)),
});
//Bind menitems list to ur treeview
tvLeftMenu.ItemsSource = MenuItems;
谢谢
Anil
Thanks
Anil
这篇关于图像(图标)应显示在树视图左侧的数据库中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!