views:

22

answers:

3

Hai am creating a usercontol with two textblock and one listbox. i can able to pass data to textblock in my usercontorl. but i cannot pass the data to my listbox in usercontrol. how to pass my data in the usercontrol

 public partial class UserControl1 : UserControl
{
    public UserControl1()
    {
        InitializeComponent();
    }

    public string TeamName
    {
        get { return textBlock1.Text; }
        set { textBlock1.Text = value; }
    }

    public ObservableCollection<CssRpt> CssDataList
    {
        get { return listBox1.ItemsSource; }
        set { listBox1.ItemsSource = value; }
    }

}
A: 

You can check how to add data to a list box on this msdn tutorial.

npinti
A: 

Did you try assigning into .DataContext? See this answer.

KMan
A: 

Try this

YourListBox.DataSource = CssDataList
YourListBox.DisplayMember = "What u want to display"
Johnny