Поделиться через


How to: Populate Collections by Using the Collection Editor

Some Windows Presentation Foundation (WPF) controls, such as ListBox and ComboBox, are designed to contain collections of objects. While these objects can be added manually in code or in the XAML editor, a faster way to populate collections is by using the Collection Editor. The Collection Editor allows you to quickly populate collections and edit the properties of the items in a collection.

To populate a collection with the Collection Editor

  1. In the WPF Designer, select the control that contains the collection that you want to populate.

  2. In the Properties window, locate the Items property and click the ellipsis button in the Items property value cell.

    The Collection Editor opens.

  3. In the Collection Editor, select the type of the item that you want to add to the collection from the drop-down box and click Add. A new item of the selected type is added to the collection.

  4. When finished, click OK.

To edit items in a collection with the Collection Editor

  1. In the WPF Designer, select the control that contains the collection that you want to edit.

  2. In the Properties window, locate the Items property and click the ellipsis button in the Items property value cell.

    The Collection Editor opens.

  3. Select the item you want to edit from the list on the left-hand side of the Collection Editor.

  4. In the Properties grid on the right-hand side of the Collection Editor, edit the properties for the selected item.

  5. When finished, click OK.

See Also

Reference

ListBox

ComboBox

Other Resources

Using Resources