UWP Grid RowSpan with ScroolViewer - xaml

If you paste this code in the mainpage of a new UWP app (or look at the 1st picture) you can see that the orange grid is taking more space than needed (VerticalAlignment is set to top). To make it work like it should, you have to set the 2nd row's height of this grid to Auto (see 2nd picture). The problem is that I want to give the extra space to the 2nd/last row and not to distribute it across all rows.
Putting the controls in the left column inside their own grid works (obviously, because there is no rowspan) but I can't do that because when the screen narrows the stackpanel in the right column goes inside a row in the left column.
The second problem is that if you click on the orange/green/yellow space, focus goes always to the textbox in the first row (yellow).
UPDATE: both problems are fixed without the scrollviewer but I clearly need it.
<Page
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ScrollViewer Background="DarkGreen" VerticalScrollBarVisibility="Auto">
<Grid Background="DarkOrange" Margin="10" VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Background="Yellow">
<TextBlock Text="Title" />
<TextBox Margin="20" />
</StackPanel>
<Grid Grid.Row="1" Background="DeepPink" VerticalAlignment="Top">
<ListView Margin="10" VerticalAlignment="Top">
<ListView.Items>
<TextBlock Text="Item1" />
</ListView.Items>
</ListView>
</Grid>
<StackPanel Grid.Column="1" Grid.RowSpan="2" Background="Blue" VerticalAlignment="Top">
<StackPanel>
<TextBlock Text="Title1" />
<GridView Margin="0,10,0,0">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Horizontal" MaximumRowsOrColumns="4" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.Items>
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
</GridView.Items>
</GridView>
</StackPanel>
<StackPanel>
<TextBlock Text="Title2" />
<GridView Margin="0,10,0,0">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Horizontal" MaximumRowsOrColumns="4" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.Items>
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
<Rectangle Width="80" Height="80" Fill="White" />
</GridView.Items>
</GridView>
</StackPanel>
</StackPanel>
</Grid>
</ScrollViewer>
</Grid>

I found a workaround. Since the first row is not going to expand or change, I set the first row's MaxHeight property equal to the actual height of the row at runtime.
For the second problem set the IsTabStop property of the scrollviewer to True as explained here:
https://social.msdn.microsoft.com/Forums/windowsapps/en-US/32e026dd-8338-4c19-a7d6-1bb8797044b3/first-input-control-in-the-scroll-viewer-is-always-getting-focused?prof=required

Related

Controls going outside of window

I'm attempting to make a "information" page, but when I get to a finished product this happens:
Video of application
So as you can see the poster of the movie and the description is fine to start with, but when the user attempts to use a different size than default it doesn't resize so the the user can see the same information.
Code:
<Grid>
<Image
Name="Backdrop"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stretch="UniformToFill" />
<Grid Background="{ThemeResource SystemControlAcrylicElementBrush}">
<StackPanel Margin="80">
<StackPanel Orientation="Horizontal">
<Button Click="ButtonBase_OnClick" Style="{StaticResource MaterialDesignRaisedLightButton}">
<SymbolIcon Symbol="Back" />
</Button>
<TextBlock
Margin="20,0,0,0"
VerticalAlignment="Center"
Style="{StaticResource TitleTextBlockStyle}"
Text="{x:Bind Movie.Title}" />
</StackPanel>
<Border
Margin="0,10,0,10"
VerticalAlignment="Bottom"
BorderBrush="Gray"
BorderThickness="1"
Style="{StaticResource DownwardDropShadow}" />
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<StackPanel>
<Grid>
<Image
Name="Poster"
MinWidth="200"
MaxWidth="500"
Margin="10" />
<Button
Width="100"
Height="100"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="{ThemeResource SystemControlAcrylicElementBrush}"
CornerRadius="100">
<Viewbox MaxWidth="60" MaxHeight="60">
<SymbolIcon Foreground="Gray" Symbol="Play" />
</Viewbox>
</Button>
</Grid>
</StackPanel>
<StackPanel
MinWidth="300"
MaxWidth="600"
Padding="20">
<TextBlock Style="{StaticResource PageTitleStyle}" Text="Information" />
<Border
Margin="0,10,0,10"
VerticalAlignment="Bottom"
BorderBrush="Gray"
BorderThickness="1"
Style="{StaticResource DownwardDropShadow}" />
<TextBlock
Style="{StaticResource BodyTextStyle}"
Text="{x:Bind Movie.Overview}"
TextWrapping="WrapWholeWords" />
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
</Grid>
So in short, how do I keep the design, but make is so when the window changes size the image & text resizes to stay inside the window and stay visible.
Controls going outside of window
The problem is that when set root panel as StackPanel , the size of children element will be fixed. And it will not change as the window size changes. For solve the this, you could try to use Grid to replace. Please refer the following xaml layout.
<Grid>
<Image
Name="Backdrop"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Source="Assets/hello.jpg"
Stretch="UniformToFill"
/>
<Grid Background="{ThemeResource SystemControlAcrylicElementBrush}">
<Grid Margin="80" >
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="9*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Button Click="ButtonBase_OnClick">
<SymbolIcon Symbol="Back" />
</Button>
<TextBlock
Margin="20,0,0,0"
VerticalAlignment="Center"
Style="{StaticResource TitleTextBlockStyle}"
Text="Grid Test Page"
/>
</StackPanel>
<Border
Margin="0,10,0,10"
VerticalAlignment="Bottom"
BorderBrush="Gray"
BorderThickness="1"
/>
<Grid
Grid.Row="1"
Margin="0,20,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid>
<Image
Name="Poster"
MinWidth="200"
MaxWidth="500"
Margin="10"
Source="Assets/hello.jpg"
/>
<Button
Width="100"
Height="100"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="{ThemeResource SystemControlAcrylicElementBrush}"
CornerRadius="100"
>
<Viewbox MaxWidth="60" MaxHeight="60">
<SymbolIcon Foreground="Gray" Symbol="Play" />
</Viewbox>
</Button>
</Grid>
<StackPanel
Grid.Column="1"
MinWidth="300"
MaxWidth="600"
Padding="20"
>
<TextBlock Text="Information" />
<Border
Margin="0,10,0,10"
VerticalAlignment="Bottom"
BorderBrush="Gray"
BorderThickness="1"
/>
<TextBlock Text="Defines a flexible grid area that consists of columns and rows. Child elements of the Grid are measured and arranged according to their row/column assignments (set by using Grid.Row and Grid.Column attached properties) and other logic." TextWrapping="WrapWholeWords" />
</StackPanel>
</Grid>
</Grid>
</Grid>
</Grid>

Silverlight Accordion doesn't resize

I have an incredible annoying problem with accordion content template.
It shows perfectly, no problem with databinding or something else, but when i resize the browser window the tabControl inside the detail of the accordion doesn't resize at all.
It seems like the width is fixed but acctually it's not.
When the listbox has to change data because of the databinding, the tabcontrol resize perfectly to the new browser window size. Any suggestions please?
My code is:
<layoutToolkit:Accordion.ContentTemplate>
<DataTemplate>
<!--#Sinergia Wave2-->
<Grid>
<sdk:TabControl Grid.Row="1" Grid.ColumnSpan="4" Loaded="ListBox_Loaded" SizeChanged="ListaDetailControlli_SizeChanged">
<sdk:TabItem Header="Controlli">
<Grid Visibility="{Binding HasItems, Converter={StaticResource ConvertBooleanToVisible}}">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition Width="300" />
<!--Colonna del semaforo -->
<ColumnDefinition Width="44" />
<ColumnDefinition Width="300*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.ColumnSpan="4" Orientation="Horizontal">
<Grid SizeChanged="Grid_SizeChanged" Background="#FFC1C1C1" Height="25">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition Width="300" />
<!--Colonna del semaforo -->
<ColumnDefinition Width="44" />
<ColumnDefinition Width="300*" />
</Grid.ColumnDefinitions>
<dataInput:Label Grid.Column="1" FontSize="12" FontWeight="Bold" Content="Controllo" HorizontalAlignment="Left" VerticalAlignment="Center" />
<dataInput:Label Grid.Column="3" FontSize="12" FontWeight="Bold" Content="Dettagli" HorizontalAlignment="Left" VerticalAlignment="Center" />
</Grid>
</StackPanel>
<ListBox Name="ListaDetailControlli" BorderThickness="0" Grid.Row="1" Grid.ColumnSpan="4" ItemsSource="{Binding ListaControlli}" SelectionMode="Single"
SelectedItem="{Binding SelectedTask, Mode=TwoWay}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="44" />
<ColumnDefinition Width="300*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" FontSize="10" Margin="2,0,4,0" VerticalAlignment="Center" HorizontalAlignment="Stretch" TextAlignment="Left"
Text="{Binding DescrizioneControllo}" />
<Canvas Grid.Column="1"
Width="22"
Height="22"
Margin="0,0,4,0">
<Image Source="/Image/Traffic-no-light.png"
Width="22"
Height="22"
Margin="0,0,4,0" />
<Ellipse Canvas.Left="7"
Canvas.Top="2"
Width="8"
Height="8"
Fill="{Binding ColoreControllo}" />
<Ellipse Canvas.Left="7"
Canvas.Top="11"
Width="8"
Height="8"
Fill="{Binding ColoreControllo}" />
</Canvas>
<!-- #135162;dv;; Pannello Controlli -->
<TextBlock Grid.Column="2" FontSize="10" Margin="2,0,4,0" TextAlignment="Left" Text="{Binding DettaglioControllo}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</sdk:TabItem>
<sdk:TabItem Header="Task" GotFocus="TabTask_GotFocus">
<Grid VerticalAlignment="Stretch">
<Border BorderThickness="0" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Foreground="Red" FontSize="18" FontWeight="Bold" Text="Non รจ presente nessun task per il giorno selezionato" TextWrapping="Wrap"
Visibility="{Binding Path=HasTask, Converter={StaticResource ConvertBooleanToVisibleNegato}}" />
</Border>
<ScrollViewer BorderThickness="0" Visibility="{Binding Path=HasTask, Converter={StaticResource ConvertBooleanToVisible}}">
<ListBox x:Name="ListaTask" BorderThickness="0" Tag="{Binding ID_SERBATOIO}" MinWidth="250" Margin="-2,-1,-2,0" HorizontalAlignment="Stretch"
ItemContainerStyle="{StaticResource CheckBoxItemContainerStyleWithStatusDiari}" ItemsSource="{Binding ListaTask}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0">
<StackPanel>
<Border x:Name="BorderDrop" Height="20" Margin="8,0,0,0" Background="Gray" BorderThickness="4" Canvas.ZIndex="-2" CornerRadius="9"
Opacity="0.8" Padding="0" Visibility="Collapsed">
<Border.BorderBrush>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Offset="0.2" Color="Black" />
<GradientStop Offset="0.8" Color="#FFCDCCCC" />
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
<controlsLIB:TaskMultiTemp DataContext="{Binding }" PannelloOspitante="{Binding LayoutOspitante,ElementName=panValidazioneOperatori,
Mode=OneWay}"
TemplateTipo="{Binding TemplateMultiTemp,ElementName=panValidazioneOperatori,Mode=OneWay}" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
</Grid>
</sdk:TabItem>
</sdk:TabControl>
</Grid>
</DataTemplate>

Caption of a grid in a windows universal project

I am trying to set a caption (something like the caption of a html table control) for my grid control but I am not seeing any property related to that. Am I missing something ?
Currently I am thinking to set the grid caption using another TextBlock control having the same alignment with the grid... but this seems to get complicated for such a simple thing.
Do you know, is there another way to set the caption of a grid in a universal windows project ?
Add another row to your grid. Then add a TextBlock to the last row for the caption. Set the Grid ColumnSpan property, for the TextBlock, to span all of the columns in your grid.
Here is an example:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="25" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="50" />
<ColumnDefinition Width="50" />
<ColumnDefinition Width="50" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Row="0" Grid.Column="0" Fill="White" />
<Rectangle Grid.Row="0" Grid.Column="1" Fill="Black" />
<Rectangle Grid.Row="0" Grid.Column="2" Fill="White" />
<Rectangle Grid.Row="0" Grid.Column="3" Fill="Black" />
<Rectangle Grid.Row="1" Grid.Column="0" Fill="Black" />
<Rectangle Grid.Row="1" Grid.Column="1" Fill="White" />
<Rectangle Grid.Row="1" Grid.Column="2" Fill="Black" />
<Rectangle Grid.Row="1" Grid.Column="3" Fill="White" />
<Rectangle Grid.Row="2" Grid.Column="0" Fill="White" />
<Rectangle Grid.Row="2" Grid.Column="1" Fill="Black" />
<Rectangle Grid.Row="2" Grid.Column="2" Fill="White" />
<Rectangle Grid.Row="2" Grid.Column="3" Fill="Black" />
<Rectangle Grid.Row="3" Grid.Column="0" Fill="Black" />
<Rectangle Grid.Row="3" Grid.Column="1" Fill="White" />
<Rectangle Grid.Row="3" Grid.Column="2" Fill="Black" />
<Rectangle Grid.Row="3" Grid.Column="3" Fill="White" />
<TextBlock Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4"
Text="This is a Caption"
HorizontalAlignment="Center" VerticalAlignment="Center"
Foreground="Black" FontSize="10"/>
</Grid>
Currently I am thinking to set the grid caption using another TextBlock control having the same alignment with the grid... but this seems to get complicated for such a simple thing.
This is an acceptable solution, Mike Jablonski has provided a sample. If you need to ensure reusability, you can create a UserControl which using TextBlock control to show Caption, registering a dependency property is a good way to set "Caption" for this UserControl, see Dependency properties overview

Inner Items in UWP Grid not stretching

I am Having an issue with my items in this Grid not spanning the width of the screen. Sorry if my code is sloppy. A bit new at this.
Thanks in advance!
Not the full code - wasn't sure if you would need it.
<Grid x:Name="grid" Margin="0,0,0,54" VerticalAlignment="Bottom" Height="39" Style="{Binding HorizontalAlignment, ElementName=grid}" ScrollViewer.HorizontalScrollBarVisibility="Auto" >
<StackPanel Orientation="Horizontal" >
<Button Margin="0,12,0,-2" Height="32" Width="Auto" HorizontalContentAlignment="Stretch">
<Button.Content>
<Image Source="images/icon1.png" Margin="-9.667,-3,-9.667,-1"/>
</Button.Content>
</Button>
<Button Margin="0,12,0,-2" Height="32" Width="Auto" HorizontalContentAlignment="Stretch" >
<Button.Content>
<Image Source="images/icon2.png" Margin="-10,-3,-10,-1"/>
</Button.Content>
</Button>
<Border Background="#d1d3d4" x:Name="typeHeader11" Grid.Column="1" Margin="0,24,0,9" RenderTransformOrigin="0.5,0.5" Width="17" HorizontalAlignment="Stretch">
<Border.RenderTransform>
<CompositeTransform ScaleX="-1"/>
</Border.RenderTransform>
<Image Source="images/like.png"></Image>
</Border>
<Border Background="#d1d3d4" x:Name="typeHeader" Grid.Column="2" Margin="0,24,0,9" Width="67" HorizontalAlignment="Stretch">
<TextBlock Text="221" Width="20" Margin="0,7,0,10" FontSize="10.667" />
</Border>
<Border x:Name="typeHeader12" Grid.Column="1" Margin="0,24,0,9" RenderTransformOrigin="0.5,0.5" Width="17" HorizontalAlignment="Stretch">
<Border.RenderTransform>
<CompositeTransform ScaleX="-1"/>
</Border.RenderTransform>
<Image Source="images/dislike.png"></Image>
</Border>
<Border x:Name="typeHeader2" Grid.Column="2" Margin="0,24,0,9" Width="56" HorizontalAlignment="Stretch">
<TextBlock Text="221" Width="20" Margin="0,7,0,10" Foreground="#FFFDF3F3" FontSize="10.667" />
</Border>
<Border x:Name="typeHeader13" Grid.Column="1" Margin="0,24,0,9" RenderTransformOrigin="0.5,0.5" Width="17" HorizontalAlignment="Stretch">
<Border.RenderTransform>
<CompositeTransform ScaleX="-1"/>
</Border.RenderTransform>
<Image Source="images/comment.png"></Image>
</Border>
<Border Background="#d1d3d4" x:Name="typeHeader3" Grid.Column="2" Margin="0,24,0,9" Width="57" HorizontalAlignment="Stretch">
<TextBlock Text="221" Width="20" Margin="0,7,0,10" FontSize="10.667" />
</Border>
</StackPanel>
</Grid>
StackPanel does not stretch, use Grid and columns if you want to span items to the width of screen
<Grid x:Name="grid" ...>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> // Auto adjust space
<ColumnDefinition Width="Auto"/> // Auto adjust space
<ColumnDefinition Width="*"/> // * = Stretch to fill
<ColumnDefinition Width="Auto"/> // Auto adjust space
</Grid.ColumnDefinitions>
<Button Grid.Column="0" ... />
<Button Grid.Column="1" ... />
<Button Grid.Column="2" ... /> // This will now expand as you resize window
<Button Grid.Column="3" ... />
</Grid>

Extra space under bottom positioned TextBlock (Windows Phone 8)

I have a problem with positioning the TextBlock element on the bottom of the newsfeed rectangle.
I attached the image of the problem (red arrow is pointing at it). There is too much extra space at the bottom of the "timeago" TextBlock.
You can see that the problem only occurs when the movie title is short enough to fit into first line.
I would guess that this makes the StackPanel to shrink and therefore move the TextBlock with time elapsed a bit higher.
I tried changing the MinHeight of parent StackPanel to lower values or even removing the property, but it doesn't seem to work.
I am guessing that the problem is with the "inner" StackPanel containing the content, stars (not visible) and "timeago"
This is the DataTemplate of my LongListSelector
<DataTemplate>
<Grid Margin="12,2,5,4" >
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Rectangle Fill="{StaticResource PhoneAccentBrush}"
Opacity="0.75"
Margin="0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"/>
<StackPanel Grid.Row="0" Orientation="Horizontal"
Background="Transparent"
Height="auto"
MinHeight="99"
Width="auto">
<Grid HorizontalAlignment="Center"
Background="#FFFFC700"
Height="auto"
Width="99">
<Image Source="{Binding ImageUrl}"
Height="auto"
Width="auto"
Stretch="UniformToFill"
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Stretch">
</Image>
</Grid>
<StackPanel Width="311" Margin="8,-7,0,0">
<TextBlock Margin="10,15,15,0" Text="{Binding Content}" Style="{StaticResource NewsFeedHighlitedContent}" FontSize="24" />
<Grid Margin="10,5,0,15" Visibility="{Binding StarsVisibility}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Image Source="{Binding StarOne}" Height="30" Margin="0,0" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="0" />
<Image Source="{Binding StarTwo}" Height="30" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="1" />
<Image Source="{Binding StarThree}" Height="30" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="2" />
<Image Source="{Binding StarFour}" Height="30" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="3" />
<Image Source="{Binding StarFive}" Height="30" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="4" />
</Grid>
<TextBlock Text="{Binding Time}" Margin="8,14,25,7" VerticalAlignment="Bottom" Style="{StaticResource NewsTimeAgoStyle}" />
</StackPanel>
</StackPanel>
</Grid>
</DataTemplate>
And the style for "NewsTimeAgoStyle"
<Style x:Key="NewsTimeAgoStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="20"/>
<Setter Property="FontFamily" Value="Segoe WP Light" />
<Setter Property="Margin" Value="0,14,20,0" />
<Setter Property="Opacity" Value="0.8" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
Does anybody have any clue on how to solve this problem?
I am not sure but the problem might be because you are using StackPanel to display title and time ago text. I have changed your DataTemplate little bit to use Grid Panel. Try this and see this make any difference
<DataTemplate>
<Grid Margin="12,2,5,4" >
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Rectangle Fill="{StaticResource PhoneAccentBrush}"
Opacity="0.75"
Margin="0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"/>
<Grid Grid.Row="0"
Background="Transparent"
Height="auto"
MinHeight="99">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="99"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid HorizontalAlignment="Center"
Background="#FFFFC700">
<Image Source="{Binding ImageUrl}"
Height="auto"
Width="auto"
Stretch="UniformToFill"
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Stretch">
</Image>
</Grid>
<Grid Width="311" Margin="8,-7,0,0" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Margin="10,15,15,0" Text="{Binding Content}" Style="{StaticResource NewsFeedHighlitedContent}" FontSize="24" />
<Grid Margin="10,5,0,15" Visibility="{Binding StarsVisibility}" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Image Source="{Binding StarOne}" Height="30" Margin="0,0" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="0" />
<Image Source="{Binding StarTwo}" Height="30" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="1" />
<Image Source="{Binding StarThree}" Height="30" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="2" />
<Image Source="{Binding StarFour}" Height="30" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="3" />
<Image Source="{Binding StarFive}" Height="30" Width="30" Stretch="UniformToFill" Grid.Row="0" Grid.Column="4" />
</Grid>
<TextBlock Text="{Binding Time}" Margin="8,14,25,7" Grid.Row="2" VerticalAlignment="Bottom" Style="{StaticResource NewsTimeAgoStyle}" />
</Grid>
</Grid>
</Grid>
</DataTemplate>