-2

I have a question like this, I have two pages and have one button in each page, like this mainpage.xaml and second page.xaml, my button in mainpage was disabled with this code: <Button Name="one" IsEnabled="False" Content="Button" />. Now I want to enable this button with another button that placed in second page.xaml, how I can access the button in mainpage.xaml and make it enable?

I can't access one.isenabled=true in second page, what can I do?

Rodrigo Taboada
  • 2,727
  • 4
  • 24
  • 27
  • What does your (relevant) code look like? What efforts have you made so far, where have those efforts gone wrong (what did they do that they shouldn't, what didn't they do that they should)? – David Thomas Feb 14 '15 at 02:04
  • possible duplicate of [How to use an accesskey on a WPF Button with a custom ContentTemplate?](http://stackoverflow.com/questions/7416303/how-to-use-an-accesskey-on-a-wpf-button-with-a-custom-contenttemplate) – Victor2748 Feb 14 '15 at 02:07
  • i want to use this feature in my app, but i didnt know how to do this. – Nima Khodhal Feb 14 '15 at 02:17

1 Answers1

0

This is not the correct way of doing that.

You can have a global varible to read value from & set enabled/disabled accordingly, send data through URIs (Navigation Contexts) etc. There can be many other solutions too.

At the worst case, take reference variable of the button in code-behind of MainPage.xaml (public static Button b=one;) & access it from another page (MainPage.b.isEnabled=true;). Still, I don't recommend this.

Mangesh
  • 5,491
  • 5
  • 48
  • 71