locked
Button.Content changes in RC0/RTW? RRS feed

  • Question

  • I noticed after upgrading to RC0 or RTW that my custom Button.Content is now centered and will not stretch to the entire width of the Button.

    Is there a breaking change I missed?

    Wednesday, October 15, 2008 2:46 PM

Answers

  • Hi all,

    This property only affects a control whose template uses the HorizontalContentAlignment property as a parameter. On other controls, this property has no impact. The default is HorizontalAlignment.Center. Therefore, we need to set it implicitly.  For example,

            <Button Width="150" Height="30" HorizontalContentAlignment="Stretch" >
                <Button.ContentTemplate>
                    <DataTemplate>
                        <TextBox Text="50"></TextBox>
                    </DataTemplate>
                </Button.ContentTemplate>
            </Button>

    Best regards,

    Jonathan

    Friday, October 17, 2008 2:11 AM

All replies

  • I noticed after upgrading to RC0 or RTW that my custom Button.Content is now centered and will not stretch to the entire width of the Button.

    Is there a breaking change I missed?

    Well, it seems as though the default value for HorizontalContentAlignment must've changed.  I fixed my issue by explicitly setting it to Stretch.
    Wednesday, October 15, 2008 3:17 PM
  • Hi all,

    This property only affects a control whose template uses the HorizontalContentAlignment property as a parameter. On other controls, this property has no impact. The default is HorizontalAlignment.Center. Therefore, we need to set it implicitly.  For example,

            <Button Width="150" Height="30" HorizontalContentAlignment="Stretch" >
                <Button.ContentTemplate>
                    <DataTemplate>
                        <TextBox Text="50"></TextBox>
                    </DataTemplate>
                </Button.ContentTemplate>
            </Button>

    Best regards,

    Jonathan

    Friday, October 17, 2008 2:11 AM