I want to run some code when the Window or Control is first displayed. I can't use Loaded because that can fire more than once. I can't use Initialized because that is done by the constructor.
Is there an event somewhere between?
I want to run some code when the Window or Control is first displayed. I can't use Loaded because that can fire more than once. I can't use Initialized because that is done by the constructor.
Is there an event somewhere between?
If you don't want to use the boolean method of doing things, then you can create a method and subscribe to the Loaded event with it, then unsubscribe at the end of that method.
Example:
public MyDependencyObject(){
Loaded += OnLoaded;
}
private void OnLoaded(object sender, EventArgs args){
DoThings();
Loaded -= OnLoaded;
}