I am using a piece of code that allows me to edit another window, e.g. a textbox located inside:
var MessageBox_Window = System.Windows.Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is MessageBoxWindow) as MessageBoxWindow;
I need to be able to change the contents of this window constantly however I cannot put the var in partial class, and if I put it anywhere else it is not global. If I was to use:
ProjectName.MessageBoxWindow MessageBox_Window = System.Windows.Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is MessageBoxWindow) as MessageBoxWindow;
in partial class, whenever I try to change the contents, I get a NullReferenceException.
Is there a way of making this code global so that it can be accessed from anywhere inside a window?