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. Extend properties of Silverlight controls...

Extend properties of Silverlight controls...

Scheduled Pinned Locked Moved WPF
question
8 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.
  • S Offline
    S Offline
    salon
    wrote on last edited by
    #1

    I want to add some custom properties as well as the existing properties should remain same in the controls. Some of the controls can have the extended properties, but some controls like Textblock are sealed so can not be able to inherit other controls from the existing control. Anybody have any idea that how can we extend the exisiting silverlight control's properties? Thanks in advance...

    P 1 Reply Last reply
    0
    • S salon

      I want to add some custom properties as well as the existing properties should remain same in the controls. Some of the controls can have the extended properties, but some controls like Textblock are sealed so can not be able to inherit other controls from the existing control. Anybody have any idea that how can we extend the exisiting silverlight control's properties? Thanks in advance...

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

      If you want to extend an existing control, I'd look to use an Attached Property.

      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

      My blog | My articles | MoXAML PowerToys

      S 1 Reply Last reply
      0
      • P Pete OHanlon

        If you want to extend an existing control, I'd look to use an Attached Property.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        My blog | My articles | MoXAML PowerToys

        S Offline
        S Offline
        salon
        wrote on last edited by
        #3

        I have tried it with two ways: 1. Inheriting from teh existing control and add our custom property to it, include it in the xaml page as a new namespace and use it. But it is not working in the case when the control class is sealed for example Textblock.... 2. Created a wrapper class having the TextBlock and my custom property.Initialize the Textblock in constructor,include it in the xaml page as a new namespace and use it. But it is also not working in the case when we give the "x:name" to that control... No other idea how to do?

        P 1 Reply Last reply
        0
        • S salon

          I have tried it with two ways: 1. Inheriting from teh existing control and add our custom property to it, include it in the xaml page as a new namespace and use it. But it is not working in the case when the control class is sealed for example Textblock.... 2. Created a wrapper class having the TextBlock and my custom property.Initialize the Textblock in constructor,include it in the xaml page as a new namespace and use it. But it is also not working in the case when we give the "x:name" to that control... No other idea how to do?

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

          As I said - I'd use an Attached Property[^].

          "WPF has many lovers. It's a veritable porn star!" - Josh Smith

          My blog | My articles | MoXAML PowerToys

          S 1 Reply Last reply
          0
          • P Pete OHanlon

            As I said - I'd use an Attached Property[^].

            "WPF has many lovers. It's a veritable porn star!" - Josh Smith

            My blog | My articles | MoXAML PowerToys

            S Offline
            S Offline
            salon
            wrote on last edited by
            #5

            I have tried this link http://geekswithblogs.net/Silverlight2/archive/2008/10/31/developing-custom-controls-in-silverlight-2.aspx[^] But I am not getting the existing properties of the control.... :(

            P 1 Reply Last reply
            0
            • S salon

              I have tried this link http://geekswithblogs.net/Silverlight2/archive/2008/10/31/developing-custom-controls-in-silverlight-2.aspx[^] But I am not getting the existing properties of the control.... :(

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

              I'm not sure how many different ways to say this. Perhaps I need to shout here. USE ATTACHED PROPERTIES. That's it - full stop, finito. That's the WPF/Silverlight way of doing things. There are very few instances where you need to subclass existing controls.

              "WPF has many lovers. It's a veritable porn star!" - Josh Smith

              My blog | My articles | MoXAML PowerToys

              M 1 Reply Last reply
              0
              • P Pete OHanlon

                I'm not sure how many different ways to say this. Perhaps I need to shout here. USE ATTACHED PROPERTIES. That's it - full stop, finito. That's the WPF/Silverlight way of doing things. There are very few instances where you need to subclass existing controls.

                "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                My blog | My articles | MoXAML PowerToys

                M Offline
                M Offline
                Michael Sync
                wrote on last edited by
                #7

                Pete O'Hanlon wrote:

                USE ATTACHED PROPERTIES. That's it - full stop,

                :) easy, pete. sometimes, people just don't listen. :)

                Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

                S 1 Reply Last reply
                0
                • M Michael Sync

                  Pete O'Hanlon wrote:

                  USE ATTACHED PROPERTIES. That's it - full stop,

                  :) easy, pete. sometimes, people just don't listen. :)

                  Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

                  S Offline
                  S Offline
                  salon
                  wrote on last edited by
                  #8

                  Thanks for ur kind support.... I didn't know about the attached properties, but now it become very useful for me... :laugh:

                  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