如何在Wpf中的Datagrid中显示水平滚动条 [英] How Do I Display Horizontal Scroll Bar In Datagrid In Wpf

查看:1713
本文介绍了如何在Wpf中的Datagrid中显示水平滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



任何人都可以帮助我,你的答案非常受欢迎。

问题:只有点击datagrid的右上角才会显示水平滚动条。但是想要一直显示它而不点击任何地方。



以下是我的代码



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

<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>

推荐答案

尝试:将DataGrid放入ScrollViewer标签内,然后设置高度,宽度等。代码示例如下所示。

Try: Put DataGrid inside ScrollViewer tag then set Height, Width etc. Code sample as shown below.
<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.


这篇关于如何在Wpf中的Datagrid中显示水平滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆