i've seen so many samples that in order to open closed window i should hide the window in closing event, but this is not fair for me if i close window in middle of my work and again open same window it showing me content where i left because i'm hiding window previously. So how can i start freshly my window after closed or hide the window.
currently i'm calling winload method which is to show fresh window after calling the show method of a hide window.
Thanks,@nagaraju.
nag
nagnag38844 gold badges2121 silver badges4646 bronze badges
2 Answers
If you want the behaviour of hide/show, you should not call Window.Close() on the window at all, but hide it by calling Window.Hide(). If the user has closed it though and a close is unavoidable, you can try the following. Override OnClosing inside the Window and set e.Cancelled to true, then call .Hide(). This should allow the window to be hidden/shown even if the user closes the window.
EDIT:
Ok I've now read your question properly ;-)So how can i start freshly my window after closed or hide the window.
When you re-show the window using the above, it will of course be the same instance as the one that was previously hidden, hence will have the same data and state. If you want completely new contents you need to create a new Window() and call Window.Show() on that. If you hide/show as above then you'll get the window back in exactly the same state before it was hidden.
Are you using the MVVM pattern in your WPF application? If so, you could try the following. By having all the data in your ViewModel and bound to by the View (ie: no business logic or data in the code behind of the Window), then you could invoke a method on the ViewModel to reset all data when the window is shown. Your bindings will refresh and the window state will be reset. Note this will only work if you have correctly followed MVVM and bound all elements on the main form to ViewModel properties (including sub controls).
Best regards,
Dr. ABTDr. ABT15.3k55 gold badges6060 silver badges130130 bronze badges
It really depends on the structure of your app. Since you're not maintaining state, you only need to save the actual type of window that was closed. Depending on what type of window you're using, you can assign it an ID (e.g. in its
Tag
property) so that it can be recognized later. You can then push this ID during the Closing
event in a Stack
. Then, if the user reopens it, pop the stack to get the ID and check what window that corresponds to. You can then reopen that window.Of course,
Stack
is just one data structure and it may or may not be suitable for you. Using a Stack means that user can reopen all the past windows they closed, but maybe you might just want the one window instead.Edit - basic code:
keyboardPkeyboardP62.3k1111 gold badges133133 silver badges189189 bronze badges
Not the answer you're looking for? Browse other questions tagged wpfwindows-applications or ask your own question.
In most of the modern day browsers, we can restore the last closed tabs easily with a hotkey. This feature in a browser can be very helpful when you have accidentally closed the tab you were working on. The other day I accidentally closed my entire browser while working and I wondered if there could be a way I could re-open my last used application by using a hotkey.
Luckily, there is an app which can do exactly what I had in mind. UndoClose for Windows from AddictiveTips Team is a simple tool that monitors your last closed programs or folders and maintains a list. Using this list the app can restore your last closed program or folder when you want to.
Using UndoClose
To use the tool, download the UndoClose archive file, extract it to a folder and run the Undo Close executable file. Once you launch the program you will see two prominent sections Recently Closed Folders and Recently Closed Apps. The tool will automatically start monitoring the apps and folders you close on Windows and save it in the list maintained in the respective section.
Now, when you want to re-launch the last accidently closed app or the folder, you can press the hotkeys (by default) Control + Shift + A and Control + Shift + F respectively to launch them again. You can change the app hotkey easily for both the tasks. Just set focus on the hotkey text field and press the key combination you would like to save. Once the program registers the combo, click the Change button.
If you keep on pressing the hotkeys, the app will pop out the last program or directory in the stack and open them one after another. You can also directly click a program stacked up in the list to launch the apps manually. Don’t forget to put a check on the option Run on system startup to start the program automatically every time the Windows boots up.
One thing however I missed in the program is the ability to delete folders and programs from the list. There’s no way you can delete individual items from the list or clear it all together.
Conclusion
How To Reopen Recently Closed Window
So try out the app today for a few weeks. I am sure you will find it very helpful at times when you have accidentally closed an app or a folder that’s not pinned to your taskbar or desktop, and you are feeling lazy to launch it again. Let us know if there’s a better tool out there that does the same.
Also See#Software Did You Know
The song, 'Baby' by Justin Beiber has received more than 2.5 million dislikes.
More in Windows
How to Make a Video with Pictures and Music in Windows 10
When organizing a lot of files, you'll also probably have a lot of different windows open. Move the pictures to this directory, move these documents to that work folder..oops, closed that work folder.
Now you need to dig back through the directory hierarchy to open it and make your drag-and-drop organization method fast again. This annoying occurrence can be prevented with a simple app for Windows that will let you reopen your last-closed window.
Step 1: Download and extract UndoClose.
Step 2: Run the program bydouble-clicking on the program icon in the directory you extracted itto.
Step 3: Right-click on the System Trayicon and click on Settings from the menu that appears.
Step 4: Adjust the hot keys by firstclicking on the area where the current hot key is displayed, and thenpressing your new desired key combination. Click on the Change buttonto save these hot keys.
Step 5: When the need presents itself,press the key combination set to reopen the window or program.Alternatively, you can quickly open a window or program by double-clicking its entry in the Settings window.
Gears of war ultimate edition. How can the answer be improved?
Unfortunately, you can't open your last IM or last editing tool in Photoshop, but the app is still relatively useful for file and folder organization purposes.
(Via AddictiveTips)
Uber versus Lyft: Best tips to save you money when you hail a ride.
Tips to secure your Facebook account: It doesn't take long to make sure your Facebook account is locked down.
How To Reopen A Closed Window Mac
There are easy ways to reopen closed browser tabs in most web browsers, should you close them accidentally. But there is no way to reopen folders, files and other windows in Windows, should you close them accidentally. But there are two free software, that will allow you to reopen them quickly.
Reopen recently closed folders, files and applications
GoneIn60s Tool
GoneIn60s is another 1-hour freeware which lets you do the same. It helps you recover closed applications.
Once you run the tool, its icon will rest in the notification area. To recover and reopen an accidentally closed window, right-click on the icon and select the file you wish to reopen. To recover all, simply double-click on the icon.
Features:
- Click the X or press Alt-F4 to close an application
- To recover, rightclick the tray icon and choose an application
- Doubleclick the tray icon to recover all applications
You can download GoneIn60s from here.
ReOpen Tool
ReOpen is a freeware portable app that sits in your notification area and allows you to re-open recently closed files, folders and programs with a hotkey, in Windows 7 & Vista.
For the automatic monitor to work, the Explorer Folder Options View Settings should have “Display the full path in the Title Bar” and, if available, “Display the full path in the Address Bar” checked.
Also in Windows XP make sure that, under View Toolbars that Address Bar is enabled. After setting these options, remember to push the “Apply To All Folders” button.
You can visit its Home Page. (Update – The tool seems to have disappeared from the Internet). Take a look at UndoClose for Windows instead. It lets you reopen recently closed folders and apps
TIP: Download this tool to quickly find & fix Windows errors automatically
Related Posts: