Monday, 9 September 2013

Element automatic height

Element automatic height

I have this kind of element:

Xaml:
<UserControl
x:Class="App1.CustomControls.ApplicationTile"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1.CustomControls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<Grid x:Name="Grid">
<Grid.Background>
<SolidColorBrush Color="#FF0353AE" Opacity="0.8"/>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border BorderThickness="0,3,0,0" HorizontalAlignment="Stretch"
Grid.Row="1" Grid.Column="0" VerticalAlignment="Stretch">
<Border.BorderBrush>
<SolidColorBrush Color="#FF023B7B" Opacity="0.8"/>
</Border.BorderBrush>
<Image Margin="14,10" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Source="../Assets/icn-download@2x.png"/>
</Border>
<Border BorderThickness="3,3,3,0" HorizontalAlignment="Stretch"
Grid.Row="1" Grid.Column="1" VerticalAlignment="Stretch">
<Border.BorderBrush>
<SolidColorBrush Color="#FF023B7B" Opacity="0.8"/>
</Border.BorderBrush>
</Border>
<Border BorderThickness="0,3,0,0" HorizontalAlignment="Stretch"
Grid.Row="1" Grid.Column="2" VerticalAlignment="Stretch">
<Border.BorderBrush>
<SolidColorBrush Color="#FF023B7B" Opacity="0.8"/>
</Border.BorderBrush>
<Image Margin="14,10" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Source="../Assets/btn-training@2x.png"/>
</Border>
</Grid>
</UserControl>
On my form i have a stack panel:
<StackPanel x:Name="TestStack"/>
My element stretches horizontaly, but i want it also to automattically
stretch vertically, example:
Element is 200x200 px, so if stack panel is 1000px width, than element
resizes to 1000x1000px
How to achieve this?

No comments:

Post a Comment