我在滚动查看器中有一个itemscontrol,随着元素靠近屏幕中心,它变得更大。问题是,当它变大时,它的左上角被锁定到位,它看起来像这样。WPF-在项目控件中对齐内容
我希望它看起来像这样,但我不知道如何去这样做。
编辑:新增XAML信息,如有需要,请索要C#(我虽然怀疑)
<TextBlock Name="text2" Text="hello" Margin="0,15,0,-10"/>
<ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled" Height="300" Name="Viewr" Canvas.Top="120" ScrollChanged="Viewr_ScrollChanged">
<ItemsControl Name="viewrcontent">
<Canvas Width="100" Height="100" Background="Red"/>
<Canvas Width="100" Height="100" Background="Red"/>
<Canvas Width="100" Height="100" Background="Red"/>
<Canvas Width="100" Height="100" Background="Red"/>
<Canvas Width="100" Height="100" Background="Orange" Name="hellobox"/>
<Canvas Width="100" Height="100" Background="Green" Name="midbox"/>
<Canvas Width="100" Height="100" Background="Black"/>
<Canvas Width="100" Height="100" Background="Red"/>
<Canvas Width="100" Height="100" Background="Red"/>
<Canvas Width="100" Height="100" Background="Red"/>
<Canvas Width="100" Height="100" Background="Red"/>
<Canvas Width="100" Height="100" Background="Black"/>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="FrameworkElement.Margin" Value="5"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" CanHorizontallyScroll="True"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>
你可以发布你的xaml吗? – 2014-11-20 18:40:39
对不起,xaml贴子 – Nivert9 2014-11-20 18:46:05
Viewr_ScrollChanged做什么?我认为这是改变绿色项目?您为我提供的滚动条的xaml很好,但是中心项目不会增加大小或其他任何内容,您正在尝试执行哪项操作? – 2014-11-20 18:49:19