Horizontally Stretch Content in an ItemsControl


I have a itemscontrol, but, the items are being aligned to the left and I can't figure out how to Stretch them Horizontally.

Here is my XAML:

<ItemsControl x:Name="ItemsSnaps" ItemsSource="{Binding}" HorizontalContentAlignment="Stretch"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> </StackPanel> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Button x:Name="ButtonSnap" HorizontalAlignment="Stretch" Style="{StaticResource EmptyItemSourceAction}" Tag="{Binding}" toolkit:TiltEffect.IsTiltEnabled="{Binding Converter={StaticResource IValueCheckIfSnapWasRecieved}}" Click="ButtonSnap_Click" ManipulationCompleted="ButtonSnap_ManipulationCompleted" ManipulationStarted="ButtonSnap_ManipulationStarted"> <Grid Tag="{Binding}" Height="80"> <Grid.ColumnDefinitions> <ColumnDefinition Width="80" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="60" /> </Grid.ColumnDefinitions> <Image Grid.Column="0" Source="{Binding Converter={StaticResource IValueIconFromSnapMediaType}}" Margin="10" Stretch="UniformToFill" /> <StackPanel Grid.Column="1" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal"> <TextBlock Foreground="#FF616161" Text="{Binding FallbackValue=alexerax, Converter={StaticResource IValueActiveUserFromSnap}}" FontSize="18.667"></TextBlock> <TextBlock Foreground="#FF616161" FontSize="18.667" Text="-" Margin="5,0,5,0" /> <TextBlock Foreground="#FF616161" FontSize="18.667" TextTrimming="WordEllipsis" Text="{Binding Path=Timestamp, FallbackValue=18/08/94 - 14:34, Converter={StaticResource IValueFriendlyTimeFromSnapChatTimestamp}}" /> </StackPanel> <TextBlock FontSize="13.333" Text="{Binding FallbackValue=Pending..., Converter={StaticResource IValueFriendlySnapStatus}}"> <TextBlock.Foreground> <SolidColorBrush Color="{StaticResource FapAccent}"/> </TextBlock.Foreground> </TextBlock> <ProgressBar Width="150" Visibility="{Binding Converter={StaticResource IValueCheckIfSnapIsDownloading}}" HorizontalAlignment="Stretch" IsIndeterminate="True"></ProgressBar> </StackPanel> <ContentControl VerticalAlignment="Center" Grid.Column="2"> <TextBlock Text="10" > <TextBlock.Foreground> <SolidColorBrush Color="{StaticResource FapAccent}"/> </TextBlock.Foreground> </TextBlock> </ContentControl> </Grid> </Button> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>


Could you not use %tage based grid.columns to align them? 10s in column 2 with a hard Ypx width, rest in colummn 1 of 1*px


<Grid Height="50"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <!-- scale to fit rest --> <ColumnDefinition Width="50"/> </Grid.ColumnDefinitions> <StackPanel Orientation="Vertical" Grid.Column="1"> <!-- main stuff--> </StackPanel> <StackPanel Orientation="Vertical" Grid.Column="2"> <!-- right orientated text [10s] --> </StackPanel> </Grid>


So, the issue was with my style for the empty button having HorizontalAlignment set to Left. The way VS was sized made that part of the code go off the screen so i looked right past it.


  • How to get the click event on sIFR embedded tag in IE?
  • Replacing script src using jquery not executed
  • Using Selenium, xpath cannot find 'text' element
  • Download/Save/Write a file on the client's hard disk using flash/flex
  • Adding a new element into the DOM with angularjs does not initiate it
  • Can a variable be stored within an image or div tag?
  • button in popup.html not working
  • changes in jquery 1.4.2 breaking the code?
  • Javascript (MVC) load image (byte array) from database
  • Can't delete li from to-do list
  • WP7 difficulties binding data to listbox itemssource - won't refresh
  • Accessing another variable in the same class with a click event
  • Angular page doesn't refresh after data is added or removed
  • Javascript: Looping through an array to create listeners, issue with call by reference and value?
  • How to map Request parameter in Spring?
  • Creating a setup.exe in InstallShield in Visual Studio
  • change color of jstree node
  • Animate LayoutChanges does not work properly
  • Getting unread count in Sent Folder using Google Apps Script - GMail
  • WordPress > setting permalink option via script buggy?
  • how to get data attributes of dynamically generated element
  • Cannot get text from text area
  • How to load more than one div at a time
  • Primefaces ManyCheckbox inside ui:repeat calls setter method only for last loop
  • Passing “get” parameters doesn't work, parameter not visible in the link
  • Switch to popup in python using selenium
  • Eclipse MTJ doesn't see Java ME SDK 3.0 devices
  • Selenium to click on a javascript button corresponding to a text
  • Angularjs pass function from Controller to Directive (or call controller function from directive) -
  • Remove changes from one element when event occurs on another element?
  • Problem while Building a Setup Project for a windows Service?
  • Detect when Facebook like button is clicked
  • Keep this build forever option - Jenkins
  • dc-js disable selecting slices on click for pie chart
  • Meteor: Do Something On Email Verification Confirmation
  • How to clear text inside text field when radio button is select
  • Why ng-show works with ng-repeat but ng-if doesn't? [duplicate]
  • jquery mobile loadPage not working
  • Data Validation Drop Down Box Arrow Disappearing
  • How do you join a server to an Active Directory (domain)?