I am working on a photo gallery for Windows Phone 7, and I am trying to get each image to shoot the entire screen and slide horizontally. What I am doing so far is to use a list that I have changed to scroll horizontally, but the problem is that I cannot find a way to anchor the width and height of the ListboxItem using ActualWidth and ActualHeight from the list itself. The reason I want to do this is because if the orientation of the phone changes, the size of the photos will also change to fit the screen.
Below is the code that I still have (I tried using TemplatedParent and RelativeSource, but I have to do something wrong, since it does not work at all):
<Style x:Key="PhotoGalleryItem" TargetType="ListBoxItem">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Grid x:Name="ListBoxItemRoot" HorizontalAlignment="Stretch" Margin="4,0,4,0" Width="{Binding RelativeSource={RelativeSource TemplatedParent},Path=ActualWidth}">
<Image Source="{Binding Mode=OneWay}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="controls:PhotoGallery">
<Setter Property="Background" Value="Red"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:PhotoGallery">
<Border BorderBrush="Transparent" BorderThickness="0" >
<Grid x:Name="LayoutRoot" Background="{TemplateBinding Background}">
<ScrollViewer x:Name="Scroller" VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Hidden" >
<ItemsPresenter/>
</ScrollViewer>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemContainerStyle" Value="{StaticResource PhotoGalleryItem}" />
</Style>
, ?