locked
Button with two textblocks and a rotating path = Custom Control? RRS feed

  • Question

  • I have the requirements for a button that will use 2 textblocks and a path that will be rotated on mouseEnter.

    This button will then be put in a resource and i would like to be able to use this button then set the 3 values Text1Text="Text1" Text2Text="Text2" PathData="47 73 36 F2 Z ".

    Will this sort of thing require a custom control or will i be able to use multiple contentPresenters within a button?


    Thanks in advance,

    Kirsty.
    Wednesday, June 10, 2009 10:41 AM

Answers

  • Hi,

     

    -->Will this sort of thing require a custom control or will i be able to use multiple contentPresenters within a button?

     

    In this case, I think you could achieve this by the following approaches:
    #1, Create a UserControl to contain the three UI elements, and the set this UserControl instance to the content of Buttton. By doing this way, you can reuse it handily.


    #2 Create a custom class derived from Button. And expose three dependency properties and set its default value for each individual property. Set the UI elements inside the control template. Then override the default template of Button using  ContentPresenter to bind the custom dependency  property of Button.

     

    #3 Just override the default template of Button and set the visual tree for you custom Button.

     

    As you see above, you can figure that the first method is time saving and efficient in this scenario.

    Hope this helps.

    Thanks.


    Jim Zhou -MSFT
    Thursday, June 11, 2009 12:25 PM