locked
Best Practices for Custom Control Template RRS feed

  • Question

  • Daring to quote you:"This ties the code and the template together, which is discouraged".

    Recently I was investigating Toolbar class and found some amazing stuff. How does it come that a style for Toolbar does NOT react in any way to buttons being pressed in order to show overflow popup? Is that what you call "splitting code and template"? And then in code you use your internal StyleHelper class to find names in templates. I wouldn't say that Toolbar is the most complex control of all. So how about REALLY rich controls?

    Would be grateful to see your reply.

    Tuesday, July 11, 2006 9:19 AM

Answers

  • It sounds like you're now asking about a completely unrelated question regarding the Toolbar control and how to use it.  If so, please start a new forum discussion for Toolbar.  Not mixing topics within a discussion thread makes the answers easier for other people to find in the future.  It also makes things easier now, since the Toolbar people wouldn't look in a thread titled "How to register name in a template".

    Alternatively, if we are still talking about registering names in templates for use by Storyboard, can you please rephrase the question in terms of who's registering the name and which Storyboard is looking for it?  Once I understand the template/Storyboard relationship you're looking for, I'll be happy to provide an answer.

    Thank you.

    Monday, July 17, 2006 6:30 PM

All replies

  • It sounds like you're now asking about a completely unrelated question regarding the Toolbar control and how to use it.  If so, please start a new forum discussion for Toolbar.  Not mixing topics within a discussion thread makes the answers easier for other people to find in the future.  It also makes things easier now, since the Toolbar people wouldn't look in a thread titled "How to register name in a template".

    Alternatively, if we are still talking about registering names in templates for use by Storyboard, can you please rephrase the question in terms of who's registering the name and which Storyboard is looking for it?  Once I understand the template/Storyboard relationship you're looking for, I'll be happy to provide an answer.

    Thank you.

    Monday, July 17, 2006 6:30 PM
  •  

    I think the point he is trying to make is that controls within the framework currently rely on named elements within a template (even to the degree that they have to be a certain class). For instance TextBox has to have a Decorator or ScrollViewer named PART_ContentHost. It will throw an exception otherwise.

    So I'm just curious which is it? Should we avoid relying on certain elements being there in our controls' templates or should part of our control's API be what element's the control needs if the template is overriden?

    Tuesday, July 18, 2006 5:08 PM