How to set XAML Width in percentage?
.net, c#, visual-studio, width, xaml
Solution
Is it WPF?
If yes, then wrap your control (button) in grid. Then specify the grid column definition. Example:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.2*"></ColumnDefinition>
<ColumnDefinition Width="0.8*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button Grid.Column="1" Grid.Row="0"></Button>
</Grid>
Edit: Forget to close `<Button>` tag.
Problem
I am trying to create a button in XAML with a 80% width, but I can't seem to figure out how. It's apparently not as easy as using Width="80%". I have been thinking this can be done by detecting the screen width somehow and multiply that by 0.8 and use that as the width, but I am not sure how I can do this in XAML. Perhaps this has to be done in the .cs file and then adjust the width from there. Does anyone have a solution for this?