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

Thread: Dynamic width

Hybrid View

  1. #1
    Join Date
    Jan 2010
    Posts
    2

    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?

    Thanks,
    roaster

  2. #2
    Join Date
    Apr 2007
    Location
    Florida
    Posts
    403

    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.

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

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

This is a CodeGuru survey question.


Featured


HTML5 Development Center