<TabItem Header="目录查看" Margin="0,0,-4,-3"> <TreeView x:Name="treeView" Canvas.Top="71" Canvas.Left="10" BorderThickness="0" RenderTransformOrigin="0.516,0.512" Margin="10,11,7,-3" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" ScrollViewer.CanContentScroll="True" > <TreeView.ItemContainerStyle> <Style TargetType="{x:Type TreeViewItem}"> <EventSetter Event="TreeViewItem.MouseDoubleClick" Handler="TreeViewItem_Preview"/> <EventSetter Event="TreeViewItem.PreviewMouseRightButtonDown" Handler="TreeViewItem_PreviewMouseRightButtonDown"/> </Style> </TreeView.ItemContainerStyle> <TreeView.ContextMenu> <ContextMenu Name="popMenu" StaysOpen="True" > <MenuItem Header="移动到分类" Click="opencategory"></MenuItem> <MenuItem Header="打开所在目录" Click="opendir"></MenuItem> <MenuItem Header="删除目录/模型" Click="deletedir"></MenuItem> <MenuItem Header="刷新" Click="refreshdir"></MenuItem> </ContextMenu> </TreeView.ContextMenu> </TreeView> </TabItem>
treeview控件套在tab里面,数据较多时无法完全显示,而且滚动条也显示不出来,求解==
试一试 <TreeView/>外层加个 <ScrollViewer/> 顺便去掉自带的
多谢解答.....确实这样滚动条出来了,可是treeView的内容还是有一部分看不到是什么原因呢?
@shikisama: ScrollViewer有2个属性:HorizontalScrollBarVisibility和VerticalScrollBarVisibility 你懂得
@@admin: 应该默认都是true 那就是你Tree自己的样式问题 比如Margin="10,11,7,-3" Canvas.Top="71" Canvas.Left="10" 都有可能使他显示不全 你先试试去掉这些 能显示全否
@@admin: treeview宽度没控制所以之前一直显示不出来,把ScrollViewer拖到右边就看到了...