dan gibson
dan gibson

Reputation: 3665

How to know when a XAML element is finished loading

I have a custom control I'm developing that has a collection of items. When adding an item to the collection you're meant to do:

myCustomControl.BeginAddItems();
  myCustomControl.Items.Add("a");
  myCustomControl.Items.Add("b");
  myCustomControl.Items.Add("c");
myCustomControl.EndAddItems();

If defining in XAML it would be:

<MyControl>
  <Items>
    <Item Name="a" />
    <Item Name="b" />
    <Item Name="c" />
  </Items>
</MyControl>

How can I have EndAddItems (and ideally BeginAddItems) called when loading from XAML? Is there any way that MyControl can be notified by XAML that it has finished loading?

Upvotes: 2

Views: 598

Answers (1)

Thomas Levesque
Thomas Levesque

Reputation: 292415

You can use the Loaded event

Upvotes: 2

Related Questions