Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Silverlight Controls Life Cycle RSS

4 replies

Last post Oct 06, 2008 08:54 AM by Alexander Manenko

(2)
  • Alexander Manenko

    Alexander Ma...

    Member

    436 Points

    189 Posts

    Silverlight Controls Life Cycle

    Oct 02, 2008 08:34 AM | LINK

    Hi all!

    In ASP .NET we have many stages of the page's/control's life (Initialization, Rendering, Loading, etc.) and many corresponding events (PreInit, Init, InitComplete, PreLoad, Load, etc.)

    So, what about SL controls? We have constructor, where we can't access xaml properties values (correct me if i'm wrong), we have LayoutUpdated event. That's all =(((

    Any plans to improve this situation?

  • preishuber

    preishuber

    Contributor

    3572 Points

    658 Posts

    Re: Silverlight Controls Life Cycle

    Oct 02, 2008 09:41 AM | LINK

    SL is nto ASP.NET , more WPF

    you have a lot of events in Silverlight 2 like sizechanged,Layoutupdated. Each control like canvas have its own event. You can see it best with Expression Blend (propertxys- flash icon) which events are available.

    What are you looking for?

    -Hannes

    http://www.ppedv.de
  • Alexander Manenko

    Alexander Ma...

    Member

    436 Points

    189 Posts

    Re: Silverlight Controls Life Cycle

    Oct 02, 2008 09:56 AM | LINK

    I doesn't say that SL is closer to ASP .NET or WPF or something else. It's just an example HOW IT CAN BE.

    I want callback from Initialization, Rendering, Loading (and etc) stages.

  • Yi-Lun Luo - MSFT

    Yi-Lun Luo -...

    All-Star

    25149 Points

    2759 Posts

    Microsoft

    Re: Silverlight Controls Life Cycle

    Oct 06, 2008 07:30 AM | LINK

    Hello, there're a lot of differences between Silverlight and ASP.NET. In ASP.NET, some tasks have to be done in a specific event (for example, you can't add Controls dynamically after PreInit), but these limitations don't apply to Silverlight. So in Silverlight, most of the life cycle events are useless. Let's have a look at common ASP.NET page's life cycle events:

    PreInit: You typically use it to:

    • Set master page. Silverlight doesn't support master page, although you can simulate by creating a ContentControl in a parent UserControl. And if you do, you can switch content any time you wish (at least after a Control is loaded).
    • Set theme. Silverlight doesn't support theme today.
    • Work with profiles. This doesn't apply to Silverlight at all. In Silverlight, you can either use isolated storage (use it any time you wish), or ASP.NET Profile Service to store user profiles (also call the web service any time you wish).
    • Create Controls dynamically. You can do this in Silverlight any time you wish.

    Init: You typically use it to set properties for Controls. Once again, properties can be set almost any time you wish in Silverlight.

    PreLoad: You typically use it to work with View State, which doesn't apply to Silverlight at all.

    Load: Similar to Loaded.

    Render: In a server Control, you use this event to write html tags. The rendering mechanisms are significantly different and can't be compared.

    Unload: We don't have anything similar. While most objects can be garbage collected, you have to monitor critical resources (such as file IO) carefully.

    shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.
  • Alexander Manenko

    Alexander Ma...

    Member

    436 Points

    189 Posts

    Re: Silverlight Controls Life Cycle

    Oct 06, 2008 08:54 AM | LINK

    Okay :) I understand. Thank you.