带有图标的列表框项目 [英] List box items with icons

查看:143
本文介绍了带有图标的列表框项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



我有下面的代码可以正常显示列表框项目,即文本,

但我面临的挑战是如何为列表框中的每个文本添加不同的图标,以便为每个文本显示不同的图标



xaml



xaml.cs

Hi

I have the code below which works fine for displaying listbox items i.e text,
but the challenge am having is how to add different icons for each text in the listbox for it to display different icons for each text

xaml

xaml.cs

public partial class January : PhoneApplicationPage
    {
        List<string> strings = new Liststring() 
{ "Thursday 1st 10AM & 10PM (New Year Service), Friday 2ND 6PM, ;Sunday 4TH 10AM & 7PM , };


        public January()
        {
            InitializeComponent();

            lbx.ItemsSource = strings;
            lbx.SelectionChanged += lbx_SelectionChanged;
        }

        void lbx_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

            value = lbx.SelectedIndex;
            switch (value)
                        {
                            case 0: MessageBox.Show("Morn Ist Less Isaiah 5:1-7\n\n 1  Now will I sing to my wellbeloved a song of ..........);
                                break;
                            case 1: MessageBox.Show("Ist Less Isaiah 9:1-7\n\n 1  Nevertheless the dimness shall not .................);
                                break;
                            case 2: MessageBox.Show("Morn Ist Less Psalm 146:1-10\n\n 1  Praise ye the LORD. Praise the LORD,.......  );
                                break;


                        }
        }

        public int value { get; set; }





亲切帮助



kindly help

推荐答案

看看这里:

http://www.wpf-tutorial.com/list-controls/listbox -control / [ ^ ]

有一个例子说明如何在ListBoxItems中有图像。
Have a look here:
http://www.wpf-tutorial.com/list-controls/listbox-control/[^]
There is an example how to have images in your ListBoxItems.


这篇关于带有图标的列表框项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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