locked
AdornerLayer ins SL 4 RRS feed

  • Question

  • I'm converting a WPF app to SL 4 and it was using  the AdornerLayer class, but I can find any such class in SL.  If it exists, can anyone please tell me where to find it?  if it doesnt exist, did SL replace it with a different class?

     

    Thanks.

    Thursday, July 22, 2010 12:59 PM

Answers

  • The Adorner architecture in WPF isn't that complex and you can easily copy it in Silverlight if, as Mike says, the application is at least partially under your control so you can insert an AdornerDecorator into the visual tree at the top of the page. Even if it isn't under your control you can use the popup trick to insert one.

    What you are trying to do might be more easily accomplished by simply writing a custom control though, which hosts a textbox and positions a label underneath (without affecting the measurements).

    Wednesday, July 28, 2010 5:36 AM

All replies

  • The concept doesn't really exist in Silverlight. You'll have to roll your own, maybe with a big transparent popup. 

    Thursday, July 22, 2010 6:12 PM
  • OK Thanks.  This changes a lot for me.  I need to position a tiny label at the bottom right corner of the active textbox where the top of the label would be 1 pixel below the bottom of the textbox and the label would be right aligned to the textbox.  This label will show the remaining characters allowed to enter into the textbox.  If the textbox text exceeds the max text length, then the text in the label is a negative red number.

    So my question is, without an adorner, can you recommend a way to do this?  My data entry screens use grids and not canvases.

    Thanks.

    Thursday, July 22, 2010 7:22 PM
  • I spent an entire month on this... and still trying to get a similar feature.


     If the SL application design is under your total control you can be able to do something, if not forget it...I lost more than 200 precious hours on this without any results.  Stay AWAY from silverlight if you can :)  IMHO silverlight is an homebrewed poorly documented/supported version of WPF for web.  If you goal is to loose your time silverlight is the right tool for you!  Seriously I hope there is a solution for you.... Did you simply look at createFromXaml to add/remove some kind of layer over the object at runtime?  The popup layer object seems a very good Idea but getting your textbox position/size is almost impossible could be very complicated (even impossible) but I will try this when I will have more time to loose on this ;o)

    Tuesday, July 27, 2010 9:21 PM
  • BTW, alternative method could be to do this outside silverlight

    That TextBox is available in the UIAutomation Layer and the REAL bouding rectangle of the textbox is available :) You could create a non silverlight transparent window at the right location and size.   Passing the Text or getting remaining characterscould be done by javascript bridge

    But dont I dont think we can call this solution...a solution ;o)

    Tuesday, July 27, 2010 10:15 PM
  • Thanks to Tim dawson for the Popup object suggestion.  I'm playing with the popup and it's very interresting. 

    You should defenitively consider using a popup object, it's the best option you have :

    1- Create a popup object under the root element.

    2- Register for TextChange or any other event you want

    3- In the event set the popup object location and text (the location is available in the event just translate it to plugin relative position)

    4- Show and hide the popup on object enter/leave events

    Hope this help

    Tuesday, July 27, 2010 11:59 PM
  • The Adorner architecture in WPF isn't that complex and you can easily copy it in Silverlight if, as Mike says, the application is at least partially under your control so you can insert an AdornerDecorator into the visual tree at the top of the page. Even if it isn't under your control you can use the popup trick to insert one.

    What you are trying to do might be more easily accomplished by simply writing a custom control though, which hosts a textbox and positions a label underneath (without affecting the measurements).

    Wednesday, July 28, 2010 5:36 AM