When inheriting a control in Silverlight, how to find out if its template has been applied?

Posted by herzmeister der welten on Stack Overflow See other posts from Stack Overflow or by herzmeister der welten
Published on 2010-04-20T12:50:01Z Indexed on 2010/04/20 12:53 UTC
Read the original article Hit count: 142

When inheriting a control in Silverlight, how do I find out if its template has already been applied?

I.e., can I reliably get rid of my cumbersome _hasTemplateBeenApplied field?

public class AwesomeControl : Control
{
    private bool _hasTemplateBeenApplied = false;

    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
        this._hasTemplateBeenApplied = true;
        // Stuff
    }

    private bool DoStuff()
    {
        if (this._hasTemplateBeenApplied)
        {
            // Do Stuff
        }
    }

}

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about lifecycle