How to binding items colletion into Listbox with C++? RRS feed

  • Question

  • Hi MSFT,

    I encounter a problem to binding a items collection to listbox with C++.

    I could binding a single object to listbox itemtemplate, just like following:

                Vector<String^>^ collection = ref new Vector<String^>;

                collection->Append("test name");

               listBox->ItemsSource = collection.

    But i could not binding items collection into listbox, just like following:

              Item^ item = ref new Item;//item is created by myself.

             item->title = "test title";

             item->name = "name";           

              Vector<Item^>^ collection = ref new Vector<Item^>;

             listBoxt->ItemsSource = collection;

    Maybe there is a special definition for Item managed class.

    Please give me some help for this.



    Wednesday, March 21, 2012 10:23 AM


  • Hello Mr. Wang.

    You should be define a Binding Path in the ListView.ItemTemplate like belows sample XAML code.



            <TextBlock Text="{Binding Path=title}" />

            <TextBlock Text="{Binding Path=name}" />



    Good luck.

    • Proposed as answer by Jesse Jiang Tuesday, April 3, 2012 9:25 AM
    • Marked as answer by Jesse Jiang Monday, April 9, 2012 1:38 AM
    Thursday, March 22, 2012 12:08 AM