CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: Dynamic width

  1. #1
    Join Date
    Jan 2010

    Dynamic width

    Hello All:

    I have what I hope is a simple question, but we will see. I am creating a silverlight application which has many buttons that I would like to be the same length. I am not sure about how the easy way to go about this. But what I have in mind:

    Is it possible to create a variable:
    int width = 200

    Then set the width property for every button equal to the variable 'width'? This way if I need to change the width of the buttons I can do it in one spot, instead of individually. I know how to do this in C#, I was just wondering if it is possible to do in XAML?


  2. #2
    Join Date
    Apr 2007

    Re: Dynamic width

    In your Container's Resources, do the following:
    Note: Container can be a Page, Window, Grid, StackPanel, even a Button... Any level of the hierarchy contains a Resources collection.

        <Style TargetType="{x:Type Button}">
                <Setter Property="Width" Value="200"/>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)