Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. How to access button in some other cs file

How to access button in some other cs file

Scheduled Pinned Locked Moved WPF
questioncsharpwpftutorial
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aslesh
    wrote on last edited by
    #1

    Hi i am using WPf for my app. I have created a button. I disabled that button by default. I want to enable that button in some other file( not code behind) in the project at some point of time according to my logic ( in different cs file). How can i access that button? Does any one have any idea how to do this. Santhapur.

    P 1 Reply Last reply
    0
    • A Aslesh

      Hi i am using WPf for my app. I have created a button. I disabled that button by default. I want to enable that button in some other file( not code behind) in the project at some point of time according to my logic ( in different cs file). How can i access that button? Does any one have any idea how to do this. Santhapur.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      You can use the LogicalTreeHelper class to find the button. Alternatively, you can use the FindName method in the FrameworkElement class.

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      A 1 Reply Last reply
      0
      • P Pete OHanlon

        You can use the LogicalTreeHelper class to find the button. Alternatively, you can use the FindName method in the FrameworkElement class.

        Deja View - the feeling that you've seen this post before.

        My blog | My articles

        A Offline
        A Offline
        Aslesh
        wrote on last edited by
        #3

        I did not get you Logical tree class? Can you please explain in brief

        P 1 Reply Last reply
        0
        • A Aslesh

          I did not get you Logical tree class? Can you please explain in brief

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          It's this[^] class.

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

          A 1 Reply Last reply
          0
          • P Pete OHanlon

            It's this[^] class.

            Deja View - the feeling that you've seen this post before.

            My blog | My articles

            A Offline
            A Offline
            Aslesh
            wrote on last edited by
            #5

            MainWindow w = new MainWindow(); System.Windows.DependencyObject x = System.Windows.LogicalTreeHelper.FindLogicalNode(w, "btn"); is this the correct way ? how can i change the properties of button after accessing ? santhapur

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups