I am developping a WP7 application. On the mainpage I have a ListBox. Each item contains a StackPanel and a Button. The size of the items IN the StackPanel is varying and the width of the Button is always 75px. I want the width of the part of the Stackpanel to be always 80% of the screenwidth. I use following DataTemplate for the ListBox:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Margin="0,0,0,17" toolkit:TiltEffect.IsTiltEnabled="True">
<TextBlock Text="{Binding ItemDescription}" TextWrapping="Wrap" Margin="12,0,0,0" Style="{StaticResource PhoneTextTitle2Style}" Foreground="{StaticResource PhoneAccentBrush}" />
<TextBlock Text="{Binding ItemLocation}" TextWrapping="Wrap" Margin="12,-6,0,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="{Binding ItemDate}" TextWrapping="Wrap" Margin="12,6,0,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
<Button Grid.Column="1" x:Name="deleteTaskButton" Width="75" Height="75" BorderThickness="0" Margin="0,-18,0,0" Click="DeleteTaskButtonClick">
<Button.Template>
<ControlTemplate>
<Image Source="{Binding ElementName=RemindersListBox, Path=DataContext.ImgSource}" Height="48" Width="48" />
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
I used the solution from this question. But the Grid is not resizing. How can I achieve to get the first column of the Grid to be 80% of the width, both in Landscape and Portrait mode? This has got me busy for hours already…
Thanks in advance!
The problem is that listboxitem is not stretched to whole width. Use this approach to handle this: WP7 list width issue when orientation changs