public static JhMessageBoxViewModel GetInstance(JhMessageBox manager, JhMessageBoxOptions options)
 {
     _theInstance = new JhMessageBoxViewModel(manager, options);
     return _theInstance;
 }
        /// <summary>
        /// Create a new JhMessageBoxWindow, with the given options if non-null - otherwise use the DefaultOptions.
        /// </summary>
        /// <param name="options">The options to use for this particular message-box invocation. Leave this null to use the DefaultOptions.</param>
        public JhMessageBoxWindow(JhMessageBox mgr, JhMessageBoxOptions options = null)
        {
            //Console.WriteLine("JhMessageBoxWindow ctor, with options.BackgroundTexture = " + options.BackgroundTexture.ToString());
            _manager = mgr;
            // _options has to be set before InitializeComponent, since that causes properties to be bound, and hence the DataContext creates it's view-model.
            if (options == null)
            {
                _options = mgr.DefaultOptions;
            }
            else
            {
                _options = options;
            }
            _viewModel = JhMessageBoxViewModel.GetInstance(mgr, _options);

            InitializeComponent();

            // Ensure the timeout value isn't ridiculously high (as when the caller mistakenly thinks it's in milliseconds).
            // Use the constant upper-limit value to test it against.
            if (_options.TimeoutPeriodInSeconds > JhMessageBoxOptions.MaximumTimeoutPeriodInSeconds)
            {
                _options.TimeoutPeriodInSeconds = JhMessageBoxOptions.GetDefaultTimeoutValueFor(_options.MessageType);
            }

            if (_options.IsToCenterOverParent)
            {
                this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            }

            // If the option to use custom styles for the buttons is turned off, then set these button styles to null
            // so that they do not inherit the styles of the parent application.
            if (!_options.IsCustomButtonStyles)
            {
                btnCancel.Style = btnClose.Style = btnNo.Style = btnOk.Style = btnRetry.Style = btnYes.Style = btnIgnore.Style = null;
            }

            #if SILVERLIGHT
            _viewModel.CopyCommand = new RelayCommand(
                () => OnCopyCommandExecuted()
            );
            _viewModel.StayCommand = new RelayCommand(
                () => OnStayCommandExecuted(),
                () => StayCommand_CanExecute()
            );
            #else
            _viewModel.CopyCommand = new RelayCommand(
                (x) => OnCopyCommandExecuted()
            );
            _viewModel.StayCommand = new RelayCommand(
                (x) => OnStayCommandExecuted(),
                (x) => StayCommand_CanExecute()
            );
            #endif

            Loaded += OnLoaded;
            #if SILVERLIGHT
            Closing += new EventHandler<System.ComponentModel.CancelEventArgs>(OnClosing);
            #else
            ContentRendered += OnContentRendered;
            Closing += new System.ComponentModel.CancelEventHandler(OnClosing);
            #endif
        }