WPF Scrollviewer starting position strange
i've got a window with 2 tabs each tab contain a Scrollviewer with same
exact properties
<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>
the difference now :
First Tab :
the grid row 0 contain a <WrapPanel> with couple <StackPanel> inside where
all controls are
the grid row 1 contain a <DataGrid> that fill the rest and has a minimum
height
Second Tab :
the grid row 0 contain a WrapPanel with couple <DockPanel> inside where
all controls are
the grid row 1 contain a <DataGrid> that fill the rest and has a minimum
height
The issue :
when i open the window there is too much control to be viewed all at once
so scroll bar or the <ScrollViewer> appear and this is perfect. BUT for
some awkward reason the second tab the scroll bar is NOT at the top but
like a bit more than 3/4 down the window. I wonder if anyone ha that issue
before and might know what i forgot there ?
what i've tried :
named the <ScrollViewer> in question and call on the form load
MyScroll.ScrollToTop(); didn't work but i guess it's because the control
doesn't exist yet.
I tried adding the GotFocus event to the <TabItem> but this baby get
triggered every time i also click a control within it. I actually found
that funny when i first click a <ComboBox> towards the end of the window.
After trying all that i found that starting on top when the <ScrollViewer>
is fist viewed is what i want and wondering if there is a way to do this
or if i am missing something.
Secondly i actually would like the <ScrollViewer> to scroll back to top
when the person navigate the <TabItem> my little go to top bug made me
realize that i actually like that.
User will rarely use more than 2 Tabs on that window so insanely perfomant
solution not required
Edit : I've found something. if i scroll back up my problematic tab and
then witch o another tab and come back, the scroll return EXACTLY where it
was bugged at.
Note that i have no events anywhere just simple bindings on for selected
value of combobox and text box. o yeah and datasource for the grid but
empty for both tab at this time.
I have 4 windows with the EXACT same formatting and only 1 tab out of 12
do that.
Edit #2 : here the full 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>
No comments:
Post a Comment