herzmeister
herzmeister

Reputation: 11297

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

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
        }
    }

}

Upvotes: 2

Views: 208

Answers (1)

AnthonyWJones
AnthonyWJones

Reputation: 189505

Nope that is the standard way to track whether the template has been applied.

Upvotes: 2

Related Questions