我试图用这样的方式安排3个全屏大小的元素(网格),当应用程序启动时,一个将在中间,一个在每一侧,它们将是不可回收的(TabNavigation =&#34 ;一旦"。)
以下是我现在所拥有的:
<ScrollViewer x:Name="scrollViewer" Width="400"
VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto"
VerticalScrollMode="Disabled" HorizontalScrollMode="Auto"
ZoomMode="Disabled"
HorizontalSnapPointsType="MandatorySingle"
HorizontalSnapPointsAlignment="Center"
TabNavigation="Once">
<StackPanel Orientation="Horizontal">
<Grid Background="Aqua" Width="400">
<TextBlock FontSize="60" Margin="0,0,30,79" HorizontalAlignment="Right" Width="339" Height="130" VerticalAlignment="Bottom">Hello World!</TextBlock>
</Grid>
<Grid Background="Green" Width="400">
<TextBlock FontSize="60" Margin="0,0,30,79" HorizontalAlignment="Right" Width="353" Height="130" VerticalAlignment="Bottom">Hello World!</TextBlock>
</Grid>
<Grid Background="Crimson" Width="400">
<TextBlock FontSize="60" Margin="0,0,30,79" HorizontalAlignment="Right" Width="353" Height="130" VerticalAlignment="Bottom">Hello World!</TextBlock>
</Grid>
</StackPanel>
</ScrollViewer>
我想要实现的是始终在第二个元素处打开应用程序。
非常感谢任何帮助。 谢谢。
答案 0 :(得分:0)
一个简单的例子,我修改了一下
我使用ItemsControl来托管项目并命名中间元素
<ItemsControl>
<Grid Background="Aqua" Width="400">
<TextBlock FontSize="60" Margin="0,0,30,79" HorizontalAlignment="Right" Width="339" Height="130" VerticalAlignment="Bottom">Hello World!</TextBlock>
</Grid>
<Grid x:Name="middle" Background="Green" Width="400">
<TextBlock FontSize="60" Margin="0,0,30,79" HorizontalAlignment="Right" Width="353" Height="130" VerticalAlignment="Bottom">Hello World!</TextBlock>
</Grid>
<Grid Background="Crimson" Width="400">
<TextBlock FontSize="60" Margin="0,0,30,79" HorizontalAlignment="Right" Width="353" Height="130" VerticalAlignment="Bottom">Hello World!</TextBlock>
</Grid>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"
IsItemsHost="True" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Template>
<ControlTemplate>
<ScrollViewer>
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
</ItemsControl>
然后在你的代码中
Loaded += (s, e) => middle.BringIntoView();