我有一个带有 2 个选项卡的窗口,每个选项卡都包含一个具有相同属性的 Scrollviewer
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CanContentScroll="False">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
</Grid>
</ScrollViewer>
现在的区别:
第一个标签:
网格行 0 包含一个<WrapPanel>
与<StackPanel>
所有控件都在其中的一对
网格第 1 行包含一个<DataGrid>
填充其余部分并具有最小高度的
第二个标签:
网格行 0 包含一个WrapPanel
与<DockPanel>
所有控件都在其中的一对
网格第 1 行包含一个<DataGrid>
填充其余部分并具有最小高度的
问题 :
当我打开窗口时,有太多控件无法一次查看,因此滚动条或<ScrollViewer>
出现,这是完美的。但是由于一些尴尬的原因,第二个选项卡滚动条不在顶部,而是在窗口下方的 3/4 以上。我想知道是否有人以前遇到过这个问题并且可能知道我在那里忘记了什么?
我试过的:
命名有
<ScrollViewer>
问题并调用表单加载MyScroll.ScrollToTop();
不起作用,但我想这是因为控件还不存在。我尝试将
GotFocus
事件添加到,<TabItem>
但每次我还单击其中的控件时都会触发这个婴儿。实际上,当我第一次单击<ComboBox>
窗口末尾的 a 时,我发现这很有趣。
在尝试了所有之后,我发现当<ScrollViewer>
我看到拳头时从顶部开始是我想要的,并且想知道是否有办法做到这一点,或者我是否遗漏了什么。
其次,我实际上希望<ScrollViewer>
当该人导航时滚动回顶部,<TabItem>
我的小错误让我意识到我真的很喜欢那样。
用户很少会在该窗口上使用超过 2 个选项卡,因此不需要非常出色的解决方案
编辑:我发现了一些东西。如果我向上滚动有问题的选项卡,然后切换另一个选项卡并返回,则滚动将完全返回它被窃听的位置。
请注意,我在任何地方都没有事件,只是对组合框和文本框的选定值进行简单绑定。o 是的,网格的数据源,但此时两个选项卡都为空。
我有 4 个具有完全相同格式的窗口,并且 12 个选项卡中只有 1 个这样做。
编辑#2:这里是完整的 xaml
<syncfusion:ChromelessWindow x:Class="prjSelection.Crating.frmCratingWestManufacturers"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:prjSelection.Crating"
Title="West Crating" Height="640" Width="1024"
UseNativeChrome="True"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
syncfusion:SkinStorage.VisualStyle="Metro" ShowActivated="True" WindowStartupLocation="CenterScreen">
<Grid>
<Grid Name="grdOverlay" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Transparent" Panel.ZIndex="99999999" Visibility="Hidden" MinWidth="150" MinHeight="200">
<Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="White" Opacity="0.8"></Rectangle>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Label HorizontalAlignment="Stretch" VerticalAlignment="Center" Content="Running Selection" FontSize="18" FontWeight="Bold"></Label>
<syncfusion:SfBusyIndicator AnimationType="Gear" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ViewboxHeight="150" ViewboxWidth="150" VerticalContentAlignment="Center" />
</StackPanel>
</Grid>
<syncfusion:TabControlExt BorderThickness="0,2,0,0" Name="tab1" AllowDrop="False" Background="White" EnableLabelEdit="False" AllowDragDrop="False" CloseButtonType="Hide" DefaultContextMenuItemVisibility="Hidden" SelectOnCreatingNewItem="False" ShowTabItemContextMenu="False" ShowTabListContextMenu="False" SnapsToDevicePixels="True" TabPanelBackground="White" UseLayoutRounding="False" TabScrollButtonVisibility="Auto" TabVisualStyle="None" TabStripPlacement="Top" TabItemSelectedForeground="White" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch">
<syncfusion:TabItemExt Header="File" Width="150" IconMargin="0" >
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CanContentScroll="False">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<WrapPanel Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Top">
<StackPanel>
<GroupBox Header="File Visual Properties" VerticalContentAlignment="Stretch" VerticalAlignment="Top" Name="grpFileVisualProperties">
<WrapPanel Orientation="Horizontal">
<DockPanel Height="25" LastChildFill="True" Width="220" Margin="2,2,0,0">
<Label Content="File Color" Height="25" Name="lblFileColor" />
<ComboBox DisplayMemberPath="Value" Height="25" ItemsSource="{Binding Path=File.Color}" Name="cboFileColor" SelectedItem="{Binding Path=File.SelectedColor, Mode=TwoWay}" Width="120" DockPanel.Dock="Right" />
<Label />
</DockPanel>
</WrapPanel>
</GroupBox>
<GroupBox Header="File Relative Properties" VerticalContentAlignment="Stretch" VerticalAlignment="Top" Name="grpFileRelativeProperties">
<WrapPanel Orientation="Horizontal">
<DockPanel Height="25" LastChildFill="True" Width="280" Margin="2,2,0,0">
<Label Content="File Type" Height="25" Name="lblFileType" />
<ComboBox DisplayMemberPath="Value" Height="25" ItemsSource="{Binding Path=File.FileType}" Name="cboFileType" SelectedItem="{Binding Path=File.SelectedFileType, Mode=TwoWay}" Width="120" DockPanel.Dock="Right" />
<Label />
</DockPanel>
</WrapPanel>
</GroupBox>
</StackPanel>
</WrapPanel>
<Grid Grid.Row="1" HorizontalAlignment="Stretch" Name="grid2" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button Content="Run Selection" FontSize="20" FontStretch="Normal" Height="46" Name="cmdFileSelection" Padding="0" Width="198.162" Canvas.Left="793.838" Canvas.Top="410" VerticalAlignment="Top" Grid.Column="2" />
<syncfusion:SfDataGrid AllowGrouping="False" AllowResizingColumns="False" AllowSorting="False" ColumnSizer="Auto" FontSize="13" GroupRowSelectionBrush="{x:Null}" ItemsSource="{Binding Path=File.ResultGrid}" Name="grdFileData" NavigationMode="Cell" ShowColumnWhenGrouped="False" VerticalContentAlignment="Stretch" Canvas.Left="898.447" Canvas.Top="462" HorizontalAlignment="Left" Grid.Column="0" MinHeight="120" MinWidth="120" />
</Grid>
</Grid>
</ScrollViewer>
</syncfusion:TabItemExt>
<syncfusion:TabItemExt Header="Box" Width="150" IconMargin="0">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CanContentScroll="False">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<WrapPanel Grid.Row="0" HorizontalAlignment="Stretch" Orientation="Horizontal">
<DockPanel Height="25" Width="375" Margin="2,2,0,0">
<Label Content="Height" Name="lblHeight" Height="25" />
<ComboBox ItemsSource="{Binding Path=Box.Height}" SelectedItem="{Binding Path=Box.SelectedHeight, Mode=TwoWay}" DisplayMemberPath="Value" Name="cboHeight" Width="200" Height="25" DockPanel.Dock="Right" />
<Label />
</DockPanel>
</WrapPanel>
<Grid Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button Content="Run Selection" FontSize="20" FontStretch="Normal" Height="46" Name="cmdBoxSelection" Padding="0" Width="198.162" Canvas.Left="793.838" Canvas.Top="410" VerticalAlignment="Top" Grid.Column="2" />
<syncfusion:SfDataGrid AllowGrouping="False" AllowResizingColumns="False" AllowSorting="False" ColumnSizer="Auto" FontSize="13" GroupRowSelectionBrush="{x:Null}" ItemsSource="{Binding Path=Box.ResultGrid}" Name="grdBoxData" NavigationMode="Cell" ShowColumnWhenGrouped="False" VerticalContentAlignment="Stretch" Canvas.Left="898.447" Canvas.Top="462" HorizontalAlignment="Left" Grid.Column="0" MinHeight="120" MinWidth="120" />
</Grid>
</Grid>
</ScrollViewer>
</syncfusion:TabItemExt>
</syncfusion:TabControlExt>
</Grid>