When a control is inherited in Silverlight, how do you know if its template has been applied?

When inheriting a control in Silverlight, how do you know if its template has already been applied?

Ie, can I reliably get rid of my bulky field _hasTemplateBeenApplied

?

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

      

}

+2


a source to share


1 answer


No, this is the standard way to track template usage.



+2


a source







All Articles