tags:

views:

132

answers:

3
private void Main_OnLayoutUpdated(object sender, EventArgs e)
        {
            label1.Content = Classes.Global.X.ToString();
            Classes.Global.PositionChanged(this);
        }

PositionChanged writes to X new x-position of window. It works, but as soon as I delete label1 it stops working. No errors.

A: 

I'll take a stab here and suggest not deleting label1, but simply setting label1's visible property to false.

At least that way you can maintain the method and not break the app.

Robb
"Maintain the method"? It's two lines. Better to solve the mystery now before the label1 issue nests itself deep.
statenjason
Fair enough. I just assumed the guy didn't want to adjust the method. Keith has a much better guess to the problem anyways.
Robb
+1  A: 

My guess, Classes.Global.X does something ( perhaps creates a singleton? ) and PositionChanged checks to see if something is null that x would of created and hence does nothing?

try var x = Classes.Global.X instead of the label.

Keith Nicholas
A: 

If you delete label1, then trying to set anything to label1 will probably through an exception which is ignored, may be object disposed exception or null reference exception would cause it, try wrapping everything in try catch and log the exception.

Akash Kava