修改了ListBox滚动条的样式,修改后虚拟化就失效了.
本来想先看下ListBox滚动条的默认样式;
在这里先看看有大侠知道怎么解决不?
本来想先看下ListBox滚动条的默认样式;
在这里先看看有大侠知道怎么解决不?
解决方案 »
- ================请问bool类型是不是不能被序列化?===================================
- 向数据库添加打开的本地文件时 怎么获取文件地址?
- wince 智能设备 datagrid
- VS2008 我的Form怎么没有Dispose()?
- 请教DataSet的更新问题
- windows应用程序中的datagrid,怎样,隐藏列?还有怎样打印datagrid中的值?
- 如何控制像编辑框中粘贴数据的时候,只粘贴数字,不能粘贴字符?(在线等,立即结贴!)
- .net报表如何绑定数据源
- 关于Socket通讯的问题,一端用便c编,一端用便c#编,问应注意什么问题,请高手指正
- 高分求解:在服务管理器里面启动服务进程和手工双击exe启动进程的区别
- |ZYCWPF| 我写的用户控件可以,但用户自定义控件显示不出来,哪里有问题 谢谢 有测试源码
- C#作为外部进程被调用如何获得该C#进程而不是主进程的当前所在的目录
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="StandardBorderBrush" Color="#888" />
<SolidColorBrush x:Key="StandardBackgroundBrush" Color="#FFF" />
<SolidColorBrush x:Key="HoverBorderBrush" Color="#DDD" />
<SolidColorBrush x:Key="SelectedBackgroundBrush" Color="Gray" />
<SolidColorBrush x:Key="SelectedForegroundBrush" Color="White" />
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />
<SolidColorBrush x:Key="NormalBrush" Color="#888" />
<SolidColorBrush x:Key="NormalBorderBrush" Color="#888" />
<SolidColorBrush x:Key="HorizontalNormalBrush" Color="#888" />
<SolidColorBrush x:Key="HorizontalNormalBorderBrush" Color="#888" /> <Style x:Key="stBackBorder" TargetType="Border">
<Setter Property="BorderBrush" Value="#909090"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="#909090"/>
<Setter Property="CornerRadius" Value="1"/>
</Style>
<LinearGradientBrush x:Key="ListBoxBackgroundBrush"
StartPoint="0,0" EndPoint="1,0.001">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="White" Offset="0.0" />
<GradientStop Color="White" Offset="0.6" />
<GradientStop Color="#DDDDDD" Offset="1.2"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="StandardBrush"
StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF" Offset="0.0"/>
<GradientStop Color="#CCC" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush x:Key="GlyphBrush" Color="#444" />
<LinearGradientBrush x:Key="PressedBrush"
StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#BBB" Offset="0.0"/>
<GradientStop Color="#EEE" Offset="0.1"/>
<GradientStop Color="#EEE" Offset="0.9"/>
<GradientStop Color="#FFF" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush> <Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border
Name="Border"
Margin="1"
CornerRadius="2"
Background="{StaticResource NormalBrush}"
BorderBrush="{StaticResource NormalBorderBrush}"
BorderThickness="1">
<Path
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="{StaticResource GlyphBrush}"
Data="{Binding Path=Content,
RelativeSource={RelativeSource TemplatedParent}}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="Border" Property="Background"
Value="{StaticResource PressedBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground"
Value="{StaticResource DisabledForegroundBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> <Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/> <Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}"> <Border Background="#caa948" /> </ControlTemplate>
</Setter.Value>
</Setter>
</Style> <Style x:Key="ScrollBottomBarPageButton" TargetType="{x:Type RepeatButton}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border Background="#909090" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> <!--设置中间滚动条-->
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="Width" Value="11"/>
<Setter Property="Height" Value="Auto"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" MaxHeight="11"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*" MaxHeight="11"/>
</Grid.RowDefinitions>
<Border Grid.Row="0">
<!--头部图片-->
<Border.Background>
<ImageBrush ImageSource="/WPF.TControls;component/Images/rolltop.png"/>
</Border.Background>
</Border>
<Border Grid.Row="1">
<!--中间图片,设置成自动拉长-->
<Border.Background>
<ImageBrush ImageSource="/WPF.TControls;component/Images/rollback.png" TileMode="FlipY" />
</Border.Background>
</Border>
<Border Grid.Row="2">
<!--底部图片-->
<Border.Background>
<ImageBrush ImageSource="/WPF.TControls;component/Images/rollbottom.png"/>
</Border.Background>
</Border>
</Grid>
</Border>
<!--"{TemplateBinding Background}"-->
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> <ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="18"/>
<RowDefinition />
<RowDefinition Height="18"/>
</Grid.RowDefinitions>
<!--上按钮-->
<RepeatButton Grid.Row="0" Style="{StaticResource ScrollBarLineButton}" Height="18" Command="ScrollBar.LineUpCommand" Content="M 0 4 L 4 0 L 8 4 Z"/>
<Track Name="PART_Track" Grid.Row="1" IsDirectionReversed="true" >
<Track.DecreaseRepeatButton>
<RepeatButton Width="5" Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageUpCommand" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource ScrollBarThumb}" BorderBrush="{StaticResource HorizontalNormalBorderBrush}">
</Thumb>
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Width="5" Style="{StaticResource ScrollBottomBarPageButton}" Command="ScrollBar.PageDownCommand" />
</Track.IncreaseRepeatButton>
</Track>
<!--下按钮-->
<RepeatButton Grid.Row="3" Style="{StaticResource ScrollBarLineButton}" Height="18" Command="ScrollBar.LineDownCommand" Content="M 0 0 L 4 4 L 8 0 Z"/>
</Grid>
</ControlTemplate>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions> <ScrollContentPresenter/> <ScrollBar Name="PART_VerticalScrollBar"
Grid.Column="1"
Value="{TemplateBinding VerticalOffset}"
Maximum="{TemplateBinding ScrollableHeight}"
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
Template="{StaticResource VerticalScrollBar}"
ViewportSize="{TemplateBinding ViewportHeight}"
/>
<!--<ScrollBar Name="PART_HorizontalScrollBar"
Orientation="Horizontal"
Grid.Row="1"
Value="{TemplateBinding HorizontalOffset}"
Maximum="{TemplateBinding ScrollableWidth}"
ViewportSize="{TemplateBinding ViewportWidth}"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
/>
--> </Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> <Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Style.Triggers>
<!--<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Width" Value="10"/>
<Setter Property="Height" Value="Auto" />
<Setter Property="Template"
Value="{StaticResource VerticalScrollBar}" />
</Trigger>-->
</Style.Triggers>
</Style></ResourceDictionary>
<ListBox VirtualizingStackPanel.IsVirtualizing="True" x:Name="listBox1" Background="Transparent"
ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
</ListBox>去掉样式就可以正常虚拟化,我想因该使样式里有什么地方要编辑下,有问遇到这样的问题不?
<ScrollContentPresenter Grid.Column="0" Grid.Row="0" Margin="{TemplateBinding Control.Padding}" Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}" />