0

I have a windows form application in which I need to use Listview control from WPF. I am trying to add Icon and text in a list view, it is a view of completed or failed tasks with some text. I cannot use xaml so need to so it programatically. I am doing following

this.listViewComponents.Items.Add(new MyObject(Properties.Resources.Failed,"Failed"));

in the final listview, i see only assembly name and do not see Icon followed by "Failed" text. Am I missing someting?. Please help !!!

John Arlen
  • 6,539
  • 2
  • 33
  • 42

1 Answers1

0

You need a DataTemplate in the WPF project for your MyObject class.

See http://msdn.microsoft.com/en-us/library/ms742521.aspx

Greg Sansom
  • 20,442
  • 6
  • 58
  • 76
  • msdn link talks about creating DataTemplate using XAML, however I cannot use xaml, is there way to do the same in code behind? – aamruta Jul 25 '12 at 23:48
  • I definitely wouldn't recommend creating the DataTemplate in code, but it can be done - http://stackoverflow.com/a/5592399/503969 – Greg Sansom Jul 25 '12 at 23:59