Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Can any one help me, your answers is heartly appreciated.
Problem: Horizontal scroll bar only display if I click on upper right corner of datagrid. But want to display it all the time without clicking anywhere.

Following are my code

XML
<Window>
  <Grid>
    <GroupBox>
      <StackPanel>
         <DataGrid HorizontalAlignment="Center" AutoGenerateColumns="False" 
                              ScrollViewer.CanContentScroll="True"         
                              ScrollViewer.IsDeferredScrollingEnabled="True" 
                              ScrollViewer.HorizontalScrollBarVisibility="Visible" >
             <DataGrid.Columns>
                  //Some Columns here
             </DataGrid.Columns>
         </DataGrid>
      </StackPanel>
    </GroupBox>
  </Grid>
</Window>
Posted
Comments
Suvendu Shekhar Giri 9-Dec-15 6:43am    
.. is it hiding some columns?
vishal.shimpi 9-Dec-15 7:24am    
No its not hiding any column, but last column is not fully visible

1 solution

Try: Put DataGrid inside ScrollViewer tag then set Height, Width etc. Code sample as shown below.
XML
<Grid>
       <GroupBox>
           <StackPanel Orientation="Horizontal" >
               <ScrollViewer  Width="500" ScrollViewer.VerticalScrollBarVisibility="Auto" Foreground="Red">
                   <DataGrid  HorizontalAlignment="Center" AutoGenerateColumns="False" >
                       <DataGrid.Columns>
                       </DataGrid.Columns>
                   </DataGrid>
               </ScrollViewer>
           </StackPanel>
       </GroupBox>
   </Grid>


In case of issue let us know.
 
Share this answer
 
Comments
vishal.shimpi 10-Dec-15 1:23am    
Thanks Snesh, but i was facing problem with horizontal scroll bar. Now its resolved the only mistake was width of last column was '*' instead of that i should have to set it as 'auto'. Now all column is having width auto and its perfectly fine for me. :)
Member 12641914 24-Apr-20 1:53am    
You are right, I have set all the column as 'auto' as well and now it works.
Snesh Prajapati 10-Dec-15 1:36am    
Nice to hear...Thanks for update.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900