Datagrid Scroll bars

Dec 11, 2014 at 6:08 AM
I am probably doing something silly wrong here .. but i cannot get a scroll bar to appear in my list of items, my items go below the height of the screen , and dont want to implement paging .. as should never be more than
2 pages
Coordinator
Dec 11, 2014 at 6:49 AM
Can you post the XAML of your page?
Coordinator
Dec 11, 2014 at 7:51 AM
I've updated the sample app so that you can add more items to the data grid which shows the scroll viewer...

The page's XAML:
https://mytoolkit.codeplex.com/SourceControl/latest#SampleWindowsStoreApp/Views/DataGridPage.xaml

Download the sample code in the downloads section...
Dec 11, 2014 at 8:46 AM
Hi there , thanks for the quick response..

below is my xaml, il also have a look at your new updated code. Just on another note, im developing an app for a very strict environment, and will probably have to reduce this down to just the grid, as will not be allowed to have a toolkit with all the other controls etc. is there a way to do this thorugh nuget ?
<UserControl
    x:Class="Stuff.Controls.CustomerSearchResultsPane"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Stuff.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:MyToolkit.Controls"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400">

    <Grid>
        <StackPanel Orientation="Vertical">

            <TextBlock Text="Search Results" Style="{StaticResource SubheaderTextBlockStyle}" Margin="0,10,0,10"/>

            
                <controls:DataGrid
                ItemsSource="{Binding CustomerSearchModel.SearchResults}"
                DefaultOrderIndex="0"
                ScrollViewer.VerticalScrollMode="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"
                    
                    >


                    <controls:DataGrid.Columns>
                        <controls:DataGridTextColumn Width="200" 
                        Header="FullName" 
                        Binding="{Binding FullName}" 
                        />
                        <controls:DataGridTextColumn Width="200" 
                        Header="ID Number" 
                        IsAscendingDefault="False"
                        Binding="{Binding IDNumber}" 
                        />
                        <controls:DataGridTextColumn 
                        Header="Last Address" 
                        IsAscendingDefault="False"
                        Binding="{Binding LastAddressString}" 
                         />
                    </controls:DataGrid.Columns>

                    <controls:DataGrid.ItemDetailsTemplate>
                        <DataTemplate>
                       
                            <StackPanel Margin="10,10,10,5">
                                <TextBlock Text="Details: " FontWeight="ExtraBold" />
                                <StackPanel Orientation="Horizontal">
                                    <StackPanel Orientation="Vertical">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="CellNumber: " FontWeight="SemiLight"></TextBlock>
                                            <TextBlock Text="{Binding CellNumber}" Margin="15,0,15,0"></TextBlock>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="Date Of Birth: " FontWeight="SemiLight"></TextBlock>
                                            <TextBlock Text="{Binding  DateOfBirthDisplayString}"  Margin="15,0,15,0"></TextBlock>
                                        </StackPanel>
                                    </StackPanel>


                                </StackPanel>
                            </StackPanel>
                        
                    </DataTemplate>
                    </controls:DataGrid.ItemDetailsTemplate>

                </controls:DataGrid>
        </StackPanel>

    </Grid>
</UserControl>
Coordinator
Dec 11, 2014 at 8:51 AM
Do not put the datagrid in a stackpanel... This way the grid stretches to its contents and the scrollviewer is never shown... Ill write more later
Coordinator
Dec 11, 2014 at 4:56 PM
Please checkout the sample app. There you can add more items to the DataGrid which shows the scroll bars without problems... When putting the DataGrid into a StackPanel it fully stretches and the scroll bars are never shown because the height is not limited by its parent child...

If you need only the data grid you can download the source code from the page and just copy the necessary classes into a new project, but it will take some time as the DataGrid uses lots of other classes internally...