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