Looks like not easy to set up scrollbar for xamgrid when it is resizing. By default, scrollbar not sowing up.
I set following properties for a xamgrid:
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"
when browser window is resizing, xamgrid also resizing, but scrollbar not working.
How to resolve this problem?
Hi Benjamin,
I'm creating a sample to test this out. I'll update you tomorrow with my progress on it.
I've tested this in a quick sample and the scrollbars on the XamGrid appear properly while I'm resizing the browser window. Would it be possible for you to provide a sample demonstrating the behavior you initially described?
Here is the xaml for this case:
<ScrollViewer>
<Grid x:Name="LayoutRoot" Background="White" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="5">
....
</StackPanel>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="30" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<control:GridSplitter />
<ig:XamGrid x:Name="xamDataGrid" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" >
......
</ig:XamGrid>
<ContentControl Grid.Column="1" x:Name="myPlayer" VerticalContentAlignment="Center" HorizontalContentAlignment="Center">
<StackPanel Margin="5,0,10,0" HorizontalAlignment="Center" VerticalAlignment="Center" >
<Image x:Name="pImage" Source="my.png" VerticalAlignment="Center" HorizontalAlignment="Center">
<Image.Effect>
<DropShadowEffect BlurRadius="10" Opacity="1" Direction="300"/>
</Image.Effect>
</Image>
</ContentControl>
</Grid>
</ScrollViewer>
The reason a scrollbar does not appear on the XamGrid itself is because the XamGrid's height is basically set to infinite because of it's container. The XamGrid is contained within a Grid object which in turn is contained within a ScrollViewer. Because the grid is contained inside a ScrollViewer, it's height is effectively infinite so no matter how you resize the browser to cut off rows in the XamGrid, the scrollbars on the grid won't appear. You can test this by removing the ScrollViewer. Doing this, once you resize the browser window you should see the scrollbars on the XamGrid appear.
In order for the scrollbars on the XamGrid to appear you are going to need to give it an actual height.
Let me know if you have any questions on this.