Alex
Alex

Reputation: 11

WPF: Populate a listbox on window load

How can it be done with c#?

I'm able to populate a listbox on a button click, but don't know how it can be done on application startup.

Thanks.

Upvotes: 1

Views: 1025

Answers (2)

Anemoia
Anemoia

Reputation: 8116

Double click on the form (empty space).

This will generate a Window_Loaded(...) {}; event.

Put your code between the curly braces.

Upvotes: 1

Neil Knight
Neil Knight

Reputation: 48547

Put the same code in the constructor of the form.

Upvotes: 1

Related Questions