locked
newbie howto: How to bind a content presenter to resizing on a button? RRS feed

  • Question

  • I have a button template that has a content presenter in it.

    On my main project, i'm adding a grid with paths to provide artwork/iconography on top of the button...the content presenter inside the button allows this element to be visible (if i delete the content presenter out of the button, then my child elements of the button in my window won't display).  I have the button as a template, because i have 3 buttons on this window, and i want to change all three en masse, while keeping the artwork on each one separate, thus utilizing the content presenter.

    The problem is, when i go to resize a button on my window, it does resize, but the child element/artwork does not resize--it stays the same size no matter what. i cannot figure out how to get it to dynamically resize with my buttons so i can do a fly-out animation with the artwork on each button dynamically resizing to the button's size and aspect ratio.

    Can anyone point me in the right direction? 
    Purkiss
    Friday, October 3, 2008 3:44 PM

Answers

  • Make sure the horizontalcontentalignment and veritcalcontentalignment properties on the Button are set to stretch so the content stretches to take all available area.

    If you share out the XAML, we might be able to help better.

    Thanks,
    Unni

    • Marked as answer by Purkiss Tuesday, October 21, 2008 4:51 PM
    Monday, October 6, 2008 7:23 AM
    Moderator

All replies

  • Make sure the horizontalcontentalignment and veritcalcontentalignment properties on the Button are set to stretch so the content stretches to take all available area.

    If you share out the XAML, we might be able to help better.

    Thanks,
    Unni

    • Marked as answer by Purkiss Tuesday, October 21, 2008 4:51 PM
    Monday, October 6, 2008 7:23 AM
    Moderator
  • Hi Unni,

    Thanks for the tip;  what i found I could do was use grids, set the horizontal/vertical stretch as you advised, and then bind the sizing using rulers/guides where I wanted absolute sizing...otherwise, using your tip, i could allow it to stretch proportionately with the grid.

    Thanks for the help!
    Purkiss
    Tuesday, October 21, 2008 4:51 PM