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. Intercepting OrigionalSource

Intercepting OrigionalSource

Scheduled Pinned Locked Moved WPF
question
6 Posts 3 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.
  • T Offline
    T Offline
    Tristan Rhodes
    wrote on last edited by
    #1

    Hi Guys, I've got a MyUserControl i have created for my app. When i click on, or mouse over the MyUserControl, i'd like the events to be raised with the MyUserControl as the OrigionalSource. As they are composite controls, made up of numerous other controls, i get whatever child control was clicked inside MyUserControl. How do i go about achiving this? Regards Tristan

    ------------------------------- Carrier Bags - 21st Century Tumbleweed.

    A realJSOPR 2 Replies Last reply
    0
    • T Tristan Rhodes

      Hi Guys, I've got a MyUserControl i have created for my app. When i click on, or mouse over the MyUserControl, i'd like the events to be raised with the MyUserControl as the OrigionalSource. As they are composite controls, made up of numerous other controls, i get whatever child control was clicked inside MyUserControl. How do i go about achiving this? Regards Tristan

      ------------------------------- Carrier Bags - 21st Century Tumbleweed.

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      AFAIK, you can only get the control for which the event was fired. Use the VisualTreeHelper's VisualTreeHelper.FindElementsInHostCoordinates method to get all control within the mouse position from where the event was fired.

      1 Reply Last reply
      0
      • T Tristan Rhodes

        Hi Guys, I've got a MyUserControl i have created for my app. When i click on, or mouse over the MyUserControl, i'd like the events to be raised with the MyUserControl as the OrigionalSource. As they are composite controls, made up of numerous other controls, i get whatever child control was clicked inside MyUserControl. How do i go about achiving this? Regards Tristan

        ------------------------------- Carrier Bags - 21st Century Tumbleweed.

        realJSOPR Online
        realJSOPR Online
        realJSOP
        wrote on last edited by
        #3

        You could make them all global (setting a property for the element in XAML, or when you create them in code. At that point, you can subsribe to those events anywhere you want. I know it's cheating, but it works, and you can't afford to spend a week on this stuff. Right?

        .45 ACP - because shooting twice is just silly
        -----
        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

        T 1 Reply Last reply
        0
        • realJSOPR realJSOP

          You could make them all global (setting a property for the element in XAML, or when you create them in code. At that point, you can subsribe to those events anywhere you want. I know it's cheating, but it works, and you can't afford to spend a week on this stuff. Right?

          .45 ACP - because shooting twice is just silly
          -----
          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
          -----
          "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

          T Offline
          T Offline
          Tristan Rhodes
          wrote on last edited by
          #4

          Hi, thanks. that got me thinking, and in the end i implemented an ITarget interface on every control i wanted clicked, and looped through the parent controls until I found an implementor. Surely there's a better way.

          ------------------------------- Carrier Bags - 21st Century Tumbleweed.

          realJSOPR 1 Reply Last reply
          0
          • T Tristan Rhodes

            Hi, thanks. that got me thinking, and in the end i implemented an ITarget interface on every control i wanted clicked, and looped through the parent controls until I found an implementor. Surely there's a better way.

            ------------------------------- Carrier Bags - 21st Century Tumbleweed.

            realJSOPR Online
            realJSOPR Online
            realJSOP
            wrote on last edited by
            #5

            The "best" way is whatever you can get to work. Remember, your project is late (no matter if it actually is or not). :)

            .45 ACP - because shooting twice is just silly
            -----
            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

            T 1 Reply Last reply
            0
            • realJSOPR realJSOP

              The "best" way is whatever you can get to work. Remember, your project is late (no matter if it actually is or not). :)

              .45 ACP - because shooting twice is just silly
              -----
              "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
              -----
              "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

              T Offline
              T Offline
              Tristan Rhodes
              wrote on last edited by
              #6

              Well, that depends on who's maintaining the "best" way :P

              ------------------------------- Carrier Bags - 21st Century Tumbleweed.

              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