Asked by:
how to disable WPF window.

Question
-
All replies
-
-
-
Hi,
you can disable using the property IsEnabled=false;
if you do that then you will not have access to all the controls in that window, apart from that you will have access only to the standard minimize,maximize,resize buttons if available on top right corner of the title. which is non client area.
Prasad - www.beautifulmind.blog.co.in
Microsoft MVP- Proposed as answer by prasad22 Wednesday, July 1, 2009 5:25 PM
-
Hi Harshil,
according to my understanding of your query, here I would like to propose a solution:
Suppose you have your login window as 'winLogin' and next window after successful login is say 'winNext'.
Please note that, winLogin & winNext are window names like e.g. in XAML,
<Window x:Class="YourProjectName.LoginWindow" Name="winLogin" ...../>
When you find that login is successful, you will call next window as:
winNext obj = new winNext(this) // where 'this' is reference of current window which is 'winLogin'
obj.Show();
Now, in 'winNext' write following code:
public partial class winNext: Window
{winLogin objLogin = new winLogin (); // Create & Initialise an object of Login Window
winNext(winLogin obj) //Remember we have passed reference of 'winLogin' as 'this' when calling winNext after successful login
{
InitailizeComponent();
objLogin = obj; // assign the passed object of Login window to local object of winLogin created above.
}
private void Window_Loaded(object sender, RoutedEventArgs e) //Loading event of winNext
{objLogin.IsEnabled = false; // Disable the Login Window
}
}
Hope this will help...
Regards...
Laxmikant Deshpande
- Edited by Laxmikant Deshpande Monday, August 4, 2014 11:29 AM
-
I think im quiet late with my answer although I think that I can help some other people by posting a possible solution for the problem:
(other solutions I found on the internet or in this thread dont work for me)
So first I want to clarify how I understand the problem... So we want to deactivate a WPF window like calling MessageBox.Show() is doing. This can be achieved by calling the following code in the window which is supposed to be activated while the rest of the windows are deactivated:
Hide(); ShowDialog();
Calling these two methods first hides the window and then shows it as a dialog which is what we want to have.
Hide(); Show();
And now if we call the "Show" method instead of the "ShowDialog" Method the windows return to their original state.
I hope this solution helps you in your project... Regards Fabian
- Edited by Fabian T Monday, June 18, 2018 4:34 PM