Wpf Window Close Button Event

It also provides the ability to create, configure, show, and manage the lifetime of windows and dialog boxes. Shutdown method of Application class in WPF is used to stop an application immediately regardless if Close event is fired or not. To raise the event I need first to attach a handler to the Button's Click event. The second way to disable the close button is to handle the PreviewClose event. You cannot switch to other windows unless the current window is closed. WPF was just a bit more complicated. The reason for this is that the WPF default message box uses the same chrome that the default WPF window does. To cancel the closure of a form, set the Cancel property of the CancelEventArgs passed to your event handler to true. WindowControl) WindowThickness: Gets or sets the window's thickness. This demonstration shows that how a single event handler can be used for multiple controls instead of having separate event handler for each control. I have tried the same code after detaching the close event from the child window and attaching it to a button onclick on the child page and it works fine. One thing I haven't been able to find any info on is how to close a window or dialog from XAML. This article shows how to add a Close button to a WPF TabItem. In the documentation, routed event topics cross-reference similar routed events with alternative routing strategies if such routed events exist, and sections in the managed reference pages clarify the routing strategy of each routed event. One of the most common questions I've seen regarding the TabControl in Windows Forms was how to add a close button to each tab (similar to seen on tabs in Internet Explorer 7). Without talking much, lets just start with our practical and get our hands dirty with WPF! πŸ™‚. Is there a clever way to detect whether a window was closed by A user pressing the (X) button in the upper right corner of the window or window. As with the ToolTipOpening event handler, or any event handler, you can run arbitrary interface code here. In this article I am going to show you a simple way to do that. Prerequisites : Data binding, 1. As such, upon searching for β€œWPF validation,” you’ll learn how to use IDataErrorInfo. The goal of this project is to provide highly customizable window class for WPF with many options such as hidding window header icon, setting different text in the header of the window and the text displayed in the taskbar, changing standard header buttons of the windows, displaying UIElements in the header, etc. WPF: Selection enter open and well take over with Button Elements. e when you have a Dialog opened (by calling the ShowDialog() method) the user must close the dialog in order to use the Window that opened the Dialog Window. WPF Child Window with MVVM Design Pattern In this article I'll discuss how to develop reusable WPF child window using MVVM designed pattern. Create Custom Windows in WPF - Close button 5. The behavior is still the same i. The first one has a text box inside. Is there a clever way to detect whether a window was closed by A user pressing the (X) button in the upper right corner of the window or window. For instance: the purpose of a button is to be clicked, like ok and cancel , close exit and so on , … The goal is then to perform something when it's clicked, you will not use a button tag to display a text. user action can be direct like clicking on close button. GaryTexmo the MessageBoxResult. I know I can set the e. Setting a Window's WindowStyle property to ToolWindow creates a window with a thin title bar, a close button and no minimized or maximize buttons. Notice that as soon as the mouse cursor enters the Button control the event is fired and the dialog message is shown:. DMSkin-for-WPF (aka DFW) is a powerful WPF borderless window framework and control library utility. HasShutdownStarted to work. If CanExecute() returns true, the Window will be allowed to close. The child window with the binding to the CloseCommand has a CheckBox that needs to be checked to allow the child window to be closed. In WPF Dialogs are quite different from Windows Forms. This article discusses how to create a User Control in XAML and WPF using Visual Studio 2008 and how to use it in a WPF application. The following code snippet calls the Close method to close a window. This window has its own minimize/maximize/close buttons (if enabled) and can launch/be launched from another window. Fixed Close Button Position in Generic Theme. Object data type (record, rowset) 7. As you can see, you have declared a new routed event called CloseTabEvent of type Telerik. Furthermore, the window will not resize by mouse click+drag. When the new tab button is clicked, either NewItemAdded event or NewItemRequested event is raised, depending on whether the TabControl is populated from a data source (whether the TabControl's ItemsSource is set). I'm using the WPF Window (instead of User Control or Page) I have the Next button, that will close. To start, please create a new C# WPF project. A suggestion would be to make the control templateable so that we could hide / remove the close button (or other buttons) if necessary. i am not able to find the way disable close button. It also prevents a memory leak. Run the application, the following WPF Window will be displayed: The window has the Cancel button disabled. Event triggers. Write a WPF application which contains a button and handles the unload and load events of this button. The non-client area of a window is implemented by WPF and includes the parts of a window that are common to most windows, including the following: A border. If cancel, should stay same screen with out closing otherwise it close. Window is the root window of XAML applications which provides minimize/maximize option, title bar, border, and close button. And in that case, i would have to have the user to go to the task manager or provide. NET; WPF Close Popup on Button click in VB. forms to generate GUI. On one button you set IsDefault="true" this will be executed when you. How to catch the event of the window close button(red X button on window right top corner) in wpf form We have got the closing event. Basically, window event may not be assigned to MVVM. In this video tutorial i am working in WPF which stands for Windows Presentation Foundation. It is a temporary display on other content. WPF is full of surprises. NET Framework > Windows Presentation Foundation (WPF) Here is an example of how to create a log in / splash screen in WPF. Height - Height property represents the height of a Button. Now Load Employees button gets disabled and the Cancel button gets enabled. Close a Popup with Button click : Popup Β« Windows Presentation Foundation Β« C# / CSharp Tutorial. How to tell if an app is a Winforms app or WPF app by looking at project properties Tag:. On application startup, if the Window is the application's main window. I have a WPF application with a single window. Close() or Application. 1 – Volume Release Notes – 2015 Raise the Bar on Both BI and Desktop UI with Infragistics WPF Controls Infragistics WPF controls provide breadth and depth in enabling developers to bring modern, trend-setting applications to market. However, you won't be able to close if you try to click the "X" button. No GUI framework would be complete without a Button control, so of course WPF has a nice one included, and just like the rest of the framework controls, it's very flexible and will allow you to accomplish almost anything. A Windows Presentation Foundation (WPF) window consists of two distinct areas: A non-client area, which hosts the windows adornments, including an icon, title, System menu, minimize button, maximize button, restore button, close button, and a border. A Close button. When the process of dragging starts, the Compass menu appears to help you dock/undock your panes. Windows 10 App Developer We also make a button in the XAML that can. NET Framework > Windows Presentation Foundation (WPF) Here is an example of how to create a log in / splash screen in WPF. I'm using the WPF Window (instead of User Control or Page) I have the Next button, that will close. This is the code that removes the close button. In the documentation, routed event topics cross-reference similar routed events with alternative routing strategies if such routed events exist, and sections in the managed reference pages clarify the routing strategy of each routed event. Minimize, Maximize, and Restore buttons. Is there a better way to accomplish that?. left mouse button down' EventName command defined in the MainWindow. What are the types of data types are available in PC? Give me some ex for each? Two types: 1. A word of caution is that you will lose your ability to close the Window with the red X. A WPF Image/Text Button. Closing a WPF Window using MVVM and minimal code-behind So let's take a look at the Close button's event handler as it originally existed in code-behind. I know the way WPF handles Touch (Search for Touch-Events, then rerun everything with Mouse-Events). You added code to display a message while loading resources in the background. You can do this by right-clicking on the project name in Solution Explorer. WPF window close button: I've been doing some looking and this example seems like the common way to remove the close button on a wpf window. By default, a Popup control is placed relative to the XAML element in which it is defined. At the top right of the application windows, there is a windows CLOSE(X) button. docx is worth reading. It also prevents a memory leak. The problem is I can't seem to get the button bound to the command with WPF. xaml called "MainViewModel" to the "ViewModels" folder and inherit it from the ViewModelBase class. Event Handlers. Β· you can override OnClosing method. It is usually used to accomplish some animation on control such DoubleAnumatio, ColorAnimation, etc. (SessionEnding event is handled in sample but not discussed here) In case of your program it can be a call to Window. I don't want the user to be able to close the window and dispose of un-saved changes. It serves as the root of a window and provides you with the standard border, title bar and maximize, minimize and close buttons. In this video tutorial i am working in WPF which stands for Windows Presentation Foundation. If you don't like the windows style on your WPF app, or want another set of buttons for your app just for looking good in old interfaces like XP's, here is a new button for customize in your WPF app. CanExecute() and set the boolean result in the event property. NET Event Handling on Click Event in VB. the close button and generate the click event for that. 6m developers to have your questions answered on RowEditEnded event no fired when using escape key of UI for Silverlight GridView. You can get handle for a WPF window by creating an instance of the managed WindowInteropHelper class and access its Handle property in an event handler for the window’s SourceInitialized event. DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, Delphi, HTML5 or iOS & Android development. If we programmed event-oriented it would be something like this Add a button. By the way, all I'm trying to accomplish is know when foo has been closed so I can set the reference back to null. Wpf window hide close minimize button event Motori elettrici asincroni trifase serie MEC MEC Schemi di collegamento. Close button Click event, for both the. You have a modal dialog with several buttons on it and you want to automatically close it, when the user presses on some of them. DispatcherTimer class, which is the part of WPF. single and mutilrow tab layout styles) and the ability to allow the user to close some or all tabs. The two examples below gives the same look and feel in both ways. when click on window closing (X) should prompt message box using wpf and mvvm. The solution is to use WPF commands and input gestures. In WPF Dialogs are quite different from Windows Forms. CanExecute() and set the boolean result in the event property. 6m developers to have your questions answered on MainWindow "losts" focus after child RadWindow is closed of UI for WPF Window. GaryTexmo the MessageBoxResult. In the bottom row are four individual user controls that have a Windows 8 style look and feel. Standalone applications typically have a main window that both displays the main data over which the application operates and exposes the functionality to process that data through user interface (UI) mechanisms like menu bars, tool bars, and status bars. The visual interface consists of a single button, which we attach the command to using the Command property. 6m developers to have your questions answered on Handling close event when clicking on the top right cross button of UI for Silverlight Window. Create a ViewModel. This is the code that removes the close button. The example shows how to associate a RoutedCommand to a Button, create a CommandBinding, and create the event handlers which implement the RoutedCommand. Hi, I want to handle the WPF Window's Close Button Click event. ShowDialog(); Close method of the Window class is used to close a window. In Part 1 of this series on building WPF business applications, you learned to create a new WPF business application using a pre-existing architecture. so what are they?! please post example for some solutions, because i tried creating event handler, but i think it's too complicated to do that. The difference is the way you handle the Dialog Result and also how to set Dialog Results. Visual Studio 2008/2010 adds a large set of new functionality for the Visual Studio developer. The visual interface consists of a single button, which we attach the command to using the Command property. To raise the event I need first to attach a handler to the Button's Click event. Click β€œOK” and when you save your settings, an RDP window will disconnect for a second and then reconnect. Join a community of over 2. (3) Building your apps first User Interface using Blend and Visual Studio - Duration: 9:25. The purpose of this post is to show how you can create a modern contextual Menu that can enhance user experience. In this video tutorial i am working in WPF which stands for Windows Presentation Foundation. Before I go any further with this discussion, I must say that I have nothing against grids or any container control that can be used in a WPF application. If the user double-clicks on the window itself, or clicks on the maximize button in the upper right-hand corner, toggle the window between a maximized and normal state. What is the correct way to dispose this off? Am I supposed to handle the window. Run the application, the following WPF Window will be displayed: The window has the Cancel button disabled. – Stephen Stephenhaunts. Starting with version 2. Let me know if you know of a better way to create custom windows in WPF. WPF events are "routed" May traverse a hierarchy of handlers. If you supply a non-recognized action name, that name is treated as a custom action. VS2012 Debugging fails on subsequent runs. You added code to display a message while loading resources in the background. Think about how Joe User would deal with that before you do it. *, Last day my friend shared me an interesting Jquery tip on that basic v created an menu with Bounce effect on hover. If an owned window was opened by its owner window using Show, and the owner window is closed, the owned window's Closing event is not raised. Events Imports. How to clear textbox on click button. The ShowCloseButtonOnTabs property controls whether close button is shown on the tabs on not. My Windows Store app is still running in debug mode after I close it. In the following example, we will create a simple button. The second way to disable the close button is to handle the PreviewClose event. You may keep the OnClosing event handler, where you call the Model. This window has its own minimize/maximize/close buttons (if enabled) and can launch/be launched from another window. EventBase class. Close() but my FooClosed doesn't seem to be called. I know the way WPF handles Touch (Search for Touch-Events, then rerun everything with Mouse-Events). I have definately drank the cool aid, I love WPF (when MVVM is being used anyway). In WPF Dialogs are quite different from Windows Forms. The main window can execute the AppCommand. Update your main window – add a button. I've been doing some looking and this example seems like the common way to remove the close button on a wpf window. A System menu with menu items that allow users to minimize, maximize, restore, move, resize, and close a window. Recently there was a problem in our android application that users suddenly click the back button where. So, in WPF, the topmost element is most likely a window. To be able to pass an event from a publisher to a subscriber using Prism’s event aggregator, the first thing you need to do is to define the actual type of the event to be passed. wpf window close button click event (5) The easiest way is to implement ButtonClick event handler and invoke Window. Please take a moment to review it and let us know if it meets your requirements. You can use the two following attached properties:. Here's the example:. e when you have a Dialog opened (by calling the ShowDialog() method) the user must close the dialog in order to use the Window that opened the Dialog Window. I have tried the same code after detaching the close event from the child window and attaching it to a button onclick on the child page and it works fine. Handling the PreviewClose Event. Friedrich Brunzema Β· Set the Window. Using Button Controls There are three types of WPF button content controls. If an owned window was opened by its owner window using Show, and the owner window is closed, the owned window's Closing event is not raised. WPF Features Works on top of DirectX to provide more advanced UI features Support for 2D and 3D graphics, audio, and video GUI appearance and content manipulated with XAML WPF controls can be embedded in Windows Forms app and vice versa Uses vector-based graphics for resolution independence WPF apps can stand alone or run in Internet Explorer. So, i need to capture the red close window button event on the "cmd. The file contains 4 page(s) and is free to view, download or print. How to catch the event of the window close button(red X button on window right top corner) in wpf form We have got the closing event. To raise the event I need first to attach a handler to the Button's Click event. I believe, once your WPF application will need to execute something periodically, and today I would like to discuss how to do that. This demonstration shows that how a single event handler can be used for multiple controls instead of having separate event handler for each control. In the documentation, routed event topics cross-reference similar routed events with alternative routing strategies if such routed events exist, and sections in the managed reference pages clarify the routing strategy of each routed event. Implementation definition: A routed event is a CLR event that is backed by an instance of the RoutedEvent class and is processed by the Windows Presentation Foundation (WPF) event system. WPF events are "routed" May traverse a hierarchy of handlers. It also logs when Window Loaded event is raised, and, finally, when rendering is completed. From this event, I've been looked at a way to calculate how many frames are being rendered per second in a WPF application. ShowDialog(); Close method of the Window class is used to close a window. Join a community of over 2. EDIT: Also what if a user control is used in the window that contains a timer? How should the user control dispose itself properly on Window. The application has one window with a few buttons. To cancel the closure of a form, set the Cancel property of the CancelEventArgs passed to your event handler to true. WPF Child Window with MVVM Design Pattern In this article I'll discuss how to develop reusable WPF child window using MVVM designed pattern. forms to generate GUI. 6m developers to have your questions answered on Handling close event when clicking on the top right cross button of UI for Silverlight Window. XamTabControl1. I want to change the x button functionality in my WPF window. You also get minimize and maximize buttons in the window's title bar. Then: We assign the Window Title to the value of the Header attribute on the Expander element. Just call the Close method. Now we'll handle behavior of window from Code behind. When the process of dragging starts, the Compass menu appears to help you dock/undock your panes. Run the application, the following WPF Window will be displayed: The window has the Cancel button disabled. Join a community of over 2. Loading Close. Furthermore, the window will not resize by mouse click+drag. In this post, I will take you through how you can build a window in WPF that has round edges, using Visual Studio 2010 and C#. Wpf window minimize button disable exit What is the bext practise for disabling the MinimizeMaximize buttons when using a WPF window I look forward to a response fro MSFT. η§γ―γ€ζœ€γ‚‚η°‘ε˜γͺζ–Ήζ³•γŒζ—’γ«οΌˆγ»γΌοΌ‰ε«γΎγ‚Œγ¦γ„γͺいと思う。 ζ–°γ—γ„δΎε­˜ι–’δΏ‚γ‚’θΏ½εŠ γ™γ‚‹Behaviorsγ‚’δ½Ώη”¨γ™γ‚‹δ»£γ‚γ‚Šγ«γ€ζ·»δ»˜γ•γ‚ŒγŸγƒ—γƒ­γƒ‘γƒ†γ‚£γ‚’δ½Ώη”¨γ™γ‚‹γ γ‘γ§γ™γ€‚. It turns out that if you change the element that is underneath the mouse, like hiding it or changing its Z-order, you'll get a MouseLeave for the changed element and a MouseEnter for the new element that appears. Issuu company logo. The CloseButtonClick event is raised when any of the close buttons is clicked. Handling events in an MVVM WPF application when you want to invoke a command on an event other than the click event for a button, or close button of a WPF window;. By the way, all I'm trying to accomplish is know when foo has been closed so I can set the reference back to null. No GUI framework would be complete without a Button control, so of course WPF has a nice one included, and just like the rest of the framework controls, it's very flexible and will allow you to accomplish almost anything. In my last post, I discussed how to fire up a WPF window in PowerShell. When the user tries to close the Window, the behavior will use the CloseCommand's CanExecute() method to determine whether to allow the Window to close. This event corresponds to the IsInitialized property. If an owned window was opened by its owner window using Show, and the owner window is closed, the owned window's Closing event is not raised. Is there a clever way to detect whether a window was closed by A user pressing the (X) button in the upper right corner of the window or window. How to use Interaction Triggers to handle user-initiated events in WPF / MVVM. so what are they?! please post example for some solutions, because i tried creating event handler, but i think it's too complicated to do that. Display the default Window context menu on our custom window. PART_LEFT_BORDER (UIElement) GridView Edit,Update,Delete And Bind DropdownList in RowEditing event. In the first form, we will post the Designer component, and the second - Preview. But to continue this tutorial, change the window definition to inherit from this class instead of window. This Close button will only show on the selected tab. The form does not have a header section in the UI element during display at runtime but can be moved around nonetheless by clicking the body and dragging the mouse to the desired position. But I need to close the secondpage when click the close button in the second page and pass a value to the firstpage. Then it travels up the visual tree to the topmost element in the visual tree. Wpf Caliburn Micro: binding click event of faked captioned Rectangle I use VS2013, Wpf 4. This video is unavailable. Create a custom style which targets RadConfirm (for example) dialog. Width - Width property represents the width of a Button. You also learned how to load and close user controls on a main window. Simple navigation technique in WPF using MVVM The main window layout has navigation buttons on the left handle side and a ContentControl on the right hand side to. The purpose of this post is to show how you can create a modern contextual Menu that can enhance user experience. Using RDC to connect to a Win8. These lower level details are handled by your graphics framework itself. WPF > Controls > ContentControl > Window A Windows Presentation Foundation (WPF) Window represents interaction between a user and a standalone application. This is the first tutorial in the β€œGetting Started with WPF using Visual Studio 2010” series. When the user clicks either button the message box will close and the button from RESEARCH 2 at Harvey Mudd College. Basically, window event may not be assigned to MVVM. It also provides the ability to create, configure, show, and manage the lifetime of windows and dialog boxes. This is far beyond changing the template for a button. Basic Knowledge of XAML development. The event handler receives two arguments: The sender argument contains the button. This routed event will be raised when the close button of the tab control is clicked by the user. η§γ―γ€ζœ€γ‚‚η°‘ε˜γͺζ–Ήζ³•γŒζ—’γ«οΌˆγ»γΌοΌ‰ε«γΎγ‚Œγ¦γ„γͺいと思う。 ζ–°γ—γ„δΎε­˜ι–’δΏ‚γ‚’θΏ½εŠ γ™γ‚‹Behaviorsγ‚’δ½Ώη”¨γ™γ‚‹δ»£γ‚γ‚Šγ«γ€ζ·»δ»˜γ•γ‚ŒγŸγƒ—γƒ­γƒ‘γƒ†γ‚£γ‚’δ½Ώη”¨γ™γ‚‹γ γ‘γ§γ™γ€‚. com WPF Window With Close Button. NET Framework makes it very simple to prevent a Forms from closing. I've tried this, but it just doesn't do anything:. So, if you are planning to make you window cool, you have to drop the chains of the Windows themes. C# WPF Tutorial 9- Open New WPF Window on button click ( with Login ) How to open a new window using WPF WPF: Click button and open new window different. a ToolTipClosing event is available. For Visual Studio Live 2010 in Redmond, I was asked to help plan the attendee event for the conference. When creating a WPF application, the first thing you will meet is the Window class. Closed event is fired. Controls Imports Infragistics. When the click event is fired, it will expand the button width and height. The WPF user control fires the OnButtonClick event when either the OK button or the Cancel button is clicked (code shown earlier). Starting with version 2. Relative); }. WPF window has two areas: A non-client area (title, icon, buttons, border) A client area (application content) WPF Window Example: In this example we will create a transparent window with. Exiting { Remove-Module TidyModule } For PowerShell to handle this event, the user must use the exit keyword to close the session, rather than the X button at the top right of the console window "So we are. But to continue this tutorial, change the window definition to inherit from this class instead of window. It also provides the ability to create, configure, show, and manage the lifetime of windows and dialog boxes. A Close button. So you may be wondering why the button is in the dead center of the Window. Clicking the default button creates another user control which overlays on top of the previous one. Let me know if you know of a better way to create custom windows in WPF. This is the code that removes the close button. C# :: WPF Window Close Button Dec 10, 2014. The cancel button simply calls the CancelAsync() method - this will signal to the worker that the user would like to cancel the running process by setting the CancellationPending property to true, but that is all you can do from the UI thread - the rest will have to be done from inside the DoWork event. The visual interface consists of a single button, which we attach the command to using the Command property. Add a new project 2. You cannot switch to other windows unless the current window is closed. We will also need to handle the resizing of a parent Window and the movement of the Window. Window Chrome Control for WPF WindowChrome class has built-in event handler for common event related to a window, such as close, minimum and maximize. The second way to disable the close button is to handle the PreviewClose event. Shutdown method is called implicitly on Window close and MainWindow close events when Shutdown mode is set to OnLastWindowClose, OnMainWindowClose respectively. When the RadWindow gets closed the Closed event is raised. NET application. e when you have a Dialog opened (by calling the ShowDialog() method) the user must close the dialog in order to use the Window that opened the Dialog Window. to the window's resources to hide the Close button in the DXRibbonWindow control. Inside the event handler you have complete freedom to do whatever you want to any. We define a command binding on the Window, by adding it to its CommandBindings collection. I know the way WPF handles Touch (Search for Touch-Events, then rerun everything with Mouse-Events). The one hundred and seventieth part of the Windows Presentation Foundation Fundamentals tutorial continues to look at the Window control. Let's see this in action through an example. A title bar. Loading Close. Basic Knowledge of MVVM Design Pattern. the button has an. What are the comments available in PC?. xaml referencedebug fine. Abstract: Walkthrough for using WPF commanding for enabling / disabling Button with Command Property Commanding is a very useful feature in XAML based technologies (WPF, Windows Phone, Windows Store Apps, Silverlight). C#/XAML/WPF: Handling the DoubleClick event only on the Window I've taken out all of the chrome and created close button, minimise etc. t hide it a nit-pick, but I can. Make the Chromeless Window, actually behave as we would expect it to. You have a modal dialog with several buttons on it and you want to automatically close it, when the user presses on some of them. In this screencast I demonstrate how to create a fully functional custom window chrome in WPF, in just under one hour. This introductory post will provide a walkthrough on how to create your own custom looking window control with resize, drag, minimize, restore and close functionality and how to use it in your WPF applications. Imagine you have the following situation: You have 2 windows. Handle Close Button on WPF Window with PowerShell I need to disable closing the Window using Powershell and the Windows. πŸš€ As part of this release we had 7 commits which resulted in 3 issues being closed. There are other options to get the Timer behavior but one of the most efficient for a Window based operation is the DispatcherTimer. The popup will remain open as long as the user won't trigger another action (or click somewhere on the window). WindowControl) WindowInactiveBackground: Gets or sets the window's inactive background. I did three attached properties applicable to Window that use the internal API, in order to disable/hide the minimize and maximize buttons. When a program exits, it can return an integer that describes its closing status. Window Life Time in WPF:-A window lifetime in WPF starts when it is instantiated, after which it is opened, activated can be deactivated and then closed window lifetime will be ended when it is closed nothing but when its object is destroyed. Call and Raise Events in WPF from Child Control to parent window I know there are a lot of documentation on routed events in wpf, and examples. Thank you so. a Windows button control, which reacts. To start, please create a new C# WPF project. I want to change the x button functionality in my WPF window. Prerequisites : Data binding, 1. On application startup, if the Window is the application's main window.