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. RoutedCommands

RoutedCommands

Scheduled Pinned Locked Moved WPF
csharpwpfwinformshelpquestion
2 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.
  • D Offline
    D Offline
    David_ml_G
    wrote on last edited by
    #1

    Hi, this may seem like a stupid question, but I've looked everywhere and I couldn't find anything that could help me. I'm developing a WPF project and in it I have two user controls, at the moment the first has only one button and the second is pretty much a canvas with a custom border. Both of them have been added to the main window in their respective locations. What I want is, when I click the button in the first user control another control is added to the my second user control (canvas). Since I'm a bit desparate and confused about all this, I would just settle for a simple message box to show, with the code being written in the canvas code behind. Everywhere I looked said that routed commands where the best option, but I cant seem to make them work. I should also say that I can make the routed commands work only inside the first user control. Both user controls are in the same project, but have different namespaces. I'd appreciate any help and I appologise if my question seems unclear. Thanks

    A 1 Reply Last reply
    0
    • D David_ml_G

      Hi, this may seem like a stupid question, but I've looked everywhere and I couldn't find anything that could help me. I'm developing a WPF project and in it I have two user controls, at the moment the first has only one button and the second is pretty much a canvas with a custom border. Both of them have been added to the main window in their respective locations. What I want is, when I click the button in the first user control another control is added to the my second user control (canvas). Since I'm a bit desparate and confused about all this, I would just settle for a simple message box to show, with the code being written in the canvas code behind. Everywhere I looked said that routed commands where the best option, but I cant seem to make them work. I should also say that I can make the routed commands work only inside the first user control. Both user controls are in the same project, but have different namespaces. I'd appreciate any help and I appologise if my question seems unclear. Thanks

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      Well, generally WPF code is made data driven. So from the Usercontrol use DataContext to pass a Dataobject on the User Control. Make the adjustment so that the user control loads something whenever the data object is modified. We use this by implementing the data class from INotifyPropertyChanged. INotifyPropertyChanged[^] Other than that you can also keep a property/dependency property to help load the object from outside.

      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


      Visit My Website-->**

      www.abhisheksur.com

      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