Tutorial :How to know when a XAML element is finished loading



Question:

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?


Solution:1

You can use the Loaded event


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »