-
February 22nd, 2010, 08:55 PM
#1
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
-
February 26th, 2010, 04:22 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|