我有以下ListView布局:
<ScrollViewer HorizontalScrollBarVisibility="Visible">
<ListView Height="Auto" Name="lstvItems" Width="Auto" Background="#FF354D55" SelectionMode="Single" >
<ListView.View>
<GridView>
<GridViewColumn Header="Name:" DisplayMemberBinding="{Binding Name}" Width="100" />
<GridViewColumn Header="Type:" DisplayMemberBinding="{Binding Type}" Width="70" />
</GridView>
</ListView.View>
</ListView>
</ScrollViewer>
如果我向ListView添加边框并且滚动条可用,则边框会与内容一起滚动。
如何阻止这种情况发生?
答案 0 :(得分:1)
删除ScrollViewer
。
Default ListView
Template已有ScrollViewer
。
从Expression Blend获得:
<ControlTemplate TargetType="{x:Type ListView}">
<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="1" SnapsToDevicePixels="true">
<ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</ScrollViewer>
</Border>
<!-- more content here -->
</ControlTemplate>