c#


There is no way to reuse the Window after ShowDialog has been called [on hold]


As the title says - there is no way to reuse the Window after ShowDialog() has been called. Possible outcomes are that the user clicks close button which closes the Window and the expected behaviour is that the Window gets closed and disposed.
But, if user calls Window.Hide() in code, this will also dispose the Window. I found some articles where it says this is a bug but it is so weird thet they would let this out as a bug.
If you check WinForms there you can call ShowDialog() as many times as you want since Hide() just conceals the Window from the user and the ShowDialog() method is just a way of showing the Window to the user while blocking message loop of previous Window.
My question is - is there a way to successfuly call ShowDialog() after calling Hide()?
Any workarounds you might have?
The closes I can get is inheriting the Window and hiding ShowDialog() method with new one where I call Show() method and immediately after it I can call System.Windows.Threading.Dispatcher.Run(). This kinda freezes the previous message loop but the problem with this is I don't know how to pop the main execution frame from the event queue. If I caould 'undo' this method call somehow I would continue with execution of my own implementation of ShowDialog and could return a bool value.
UPDATE
Window.Hide() does not dispose the Window it simply conceals it. The issue is calling Close() or setting DialogResult to anything but null. Both of these approaches will dispose the Window and next call to ShowDialog will produce exception:
Cannot set Visibility or call Show, ShowDialog, or
WindowInteropHelper.EnsureHandle after a Window has closed.
Only Close and setting DialogResult to true/false will cause the ShowDialog() method to return.
So bottom line is that you cannot reuse the Window after calling ShowDialog() once and getting a return value from this method.

Related Links

Non-blocking Sockets vs BeginXXX vs SocketAsyncEventArgs
MVVM viewmodel events (commands?)
Powershell nothing returned from C#, same code runs in ps prompt with \r\n's removed
How do I change the foreground text color of (local variable '…' is never used) in code
HttpHandler to render a png from an array of bytes
MVC Default Area Not working
Index (zero based) must be greater than or equal to zero and less than the size of the argument list [closed]
Sprite Targeting
How to smoothly play a sequence of videos with WPF's MediaElement?
Creating Zip without third party DLLs. Getting Part URI must start with a forward slash error
Creating a list of static objects in asp.net
How can I get the StripOffsets tag to stay the same when using the LibTiff.Net 2.3 library?
Iterate a group in active directory using C Sharp
Type . insted of ,
Client HTTP Handling & ETag
Missing network sent/received

Categories

HOME
macros
azure-active-directory
leaflet
service
locale
cluster-analysis
wifi
grpc
aix
window.open
gaussian
arguments
squeak
osx-yosemite
webpack-dev-server
yacc
virtualenv
drush
watson-dialog
jinja2
responsive
background-image
web-parts
vivado-hls
connection-pooling
devexpress-mvc
aspxgridview
oracle10g
utc
login-required
blockly
visual-studio-debugging
zimbra
certbot
android-geofence
maven-2
kepserverex
delphi-xe
wufoo
ocpjp
anonymous-function
ng-class
monaca
cloudconvert
jscoverage
audio-fingerprinting
vertex
ajv
rmq
sqlproj
lattice
zsh-completion
papyrus
strtol
alfred
universe
virtualenvwrapper
altova
jira-agile
mate-desktop
git-cherry-pick
change-password
cherry-pick
android-xmlpullparser
jde
custom-build-step
code-translation
apache2-module
skscene
tvp
play-json
transbase
edgar
winforms-interop
consul-template
sparkcore
eula
android-networking
indices
cordova-3
method-overloading
frisby.js
system.io.packaging
sync
vundle
pytz
sendy
winrun4j
xps
farpoint-spread
carrier
db2-connect
google-mirror-api
grape-api
cab
azure-pack
mandelbrot
infinity.js
nsautoreleasepool
phone-state-listener
rbm
shapado
nsundomanager
sipdroid
lightopenid
meego-harmattan
quazip
silverlight-2.0
web-widget
dynamic-scope
file-icons

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App