Hi everybody. I'm having a problem with wpf listbox. my problem is that when I add items to listbox using listbox items and set the display memeber path nothing is showing. I want to use ListBoxItem or somthing similar to explicitly set tooltip for each item.
Thanks in Advance.
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for Window2.xaml
/// </summary>
public partial class Window2 : Window
{
public Window2()
{
InitializeComponent();
listbox1.DisplayMemberPath = "S";
List<ListBoxItem> l = new List<ListBoxItem>();
l.Add(new ListBoxItem() { Content = new Test() { S = "test1", I = 1 } });
l.Add(new ListBoxItem() { Content = new Test() { S = "test2", I = 2 } });
l.Add(new ListBoxItem() { Content = new Test() { S = "test3", I = 3 } });
l.Add(new ListBoxItem() { Content = new Test() { S = "test4", I = 4 } });
foreach (var item in l)
{
listbox1.Items.Add(item);
}
}
}
public class Test
{
public string S { get; set; }
public int I { get; set; }
}
}