none
Variable Width Buttons (image) question RRS feed

  • Question

  • Can anyone advise how to best create a variable width button (what control etc).

    I have the left/middle/right images, so obviously the middle will expand to the content but I will need to remove any borders on these images.

    Help!? :)

    Thursday, November 27, 2014 10:06 AM

Answers

  • Hello BudBrain,

    It seems your requirement is still a design time question, am I right?

    You want your button control fit your image for example I have the following image:

    You don't want the line in this image in your button, am I right?

    You can use the following code in your XAML:

     <Button Content="Button" HorizontalAlignment="Left" Margin="61,71,0,0" VerticalAlignment="Top" Width="803" Height="353">
                <Button.Background>
                    <ImageBrush ImageSource="TestImage1.bmp" Stretch="None"/>
                </Button.Background>
            </Button>

    With the help of Stretch="None" you can resize your button at design time.

    http://msdn.microsoft.com/en-us/library/vstudio/system.windows.media.tilebrush.stretch(v=vs.100).aspx

    If this is runtime issue, you can set the height and width of your button. I haven't find a default class for you to change your button width.

    Regards,



    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 28, 2014 8:32 AM
    Moderator