水平拉伸 ItemsControl 中的内容 [英] Horizontally Stretch Content in an ItemsControl
本文介绍了水平拉伸 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.
这是我的 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>
推荐答案
因此,问题在于我将 HorizontalAlignment
设置为 Left
的空按钮的样式.VS 大小的方式使那部分代码从屏幕上消失了,所以我看了过去.
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.
这篇关于水平拉伸 ItemsControl 中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文