开发者

image and text in listobx

开发者 https://www.devze.com 2022-12-18 18:19 出处:网络
I want to inesrt one image beside one text,like this I have to include three items in a ListBox in run time.

I want to inesrt one image beside one text,like this I have to include three items in a ListBox in run time.

If the number of items is more than 3,then the last items get removed. How can I do that in WPF,C#. And the newly added item should get add开发者_StackOverflow社区ed in first place. Now I did up to include text at runtime.

if (listBox1.Items.Count >= 3)
                listBox1.Items.RemoveAt(2);
            listBox1.Items.Insert(0,lData);

But I do nto know how to insert image(small rectangle with red colr,green color)


Anu, you might want to read about DataTemplate-s (e.g. http://msdn.microsoft.com/en-us/library/ms742521.aspx) and about styling and templating in WPF in general.

0

精彩评论

暂无评论...
验证码 换一张
取 消