Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a button on a page (page1) in a WPF application. If I press that button on page1, how can I disable a button on Window1 ? Page 1 is shown in frame from Window1.

Thanks!

share|improve this question

2 Answers

You need to create a delegate on page1

delegate void disabledButtonDelegate();

public disabledButtonDelegate disable button;

and access it on window1

 var window= new Window1();
 window.disabledButtonDelegate += DisableButton ;  //or whatever method you call to disable it
 window.Show();
share|improve this answer
Look here if I wasn't clear enough. – Antarr Byrd 14 hours ago

The Control struture is: window1 button2 Page1 button1

You want to disable button2 in window1 when clicking button2 in page1.

In order to do that, you have some options:

  1. In window1, add event handler to button1

  2. if you use mvvm, you can send message when button1 is clicked in page1's code behind. then subscribe to this message in window1's code behind.

  3. When Page1 is created, assign instance of button2 into page1. so Page1 knows button2. then it can disable button2 easily.

share|improve this answer
I'm a newbie. I'm trying to learn. Maybe an example? – Benjamin Jones 13 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.