我开发了一个 Windows 8 应用程序,其中我在 ListBox 控件中显示了一个新闻区。对于新闻项目,我使用模板。一条新闻有不同的大小。项目的大小将在 LayoutUpdate 事件之后设置。如果我用手指 Tuuch 滚动列表,则会出现闪烁效果。这些发生是因为我随后适应的项目数量。当我使用恒定大小时,闪烁效果没有问题。当我用鼠标滚动列表时没有问题。是否有可能更喜欢这种闪烁效果?每个人都有类似的问题并为我提供独奏吗?
我的模板:
<UserControl
x:Class="components.NewsItemRenderer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="150"
d:DesignWidth="560" >
<Canvas x:Name="rootCanvas"
Width="560"
Height="150">
<TextBlock x:Name="lbl_title"
Width="480"
Canvas.Left="15"
Canvas.Top="35"
MaxHeight="50"
SizeChanged="lbl_description_SizeChanged"
LayoutUpdated="lbl_title_LayoutUpdated"
Style="{StaticResource LabelTitle}"
Text="{Binding Path=message.title}"/>
<TextBlock x:Name="lbl_description"
Canvas.Left="15"
Canvas.Top="55"
Width="480"
SizeChanged="lbl_description_SizeChanged"
Style="{StaticResource LabelDescription}"
Text="{Binding Path=message.description}"/>
</Canvas>
</UserControl>
private void lbl_description_SizeChanged(object sender, SizeChangedEventArgs e)
{
lbl_description.SetValue(Canvas.TopProperty, lbl_title.ActualHeight + 45);
double _height = lbl_subject.ActualHeight + lbl_title.ActualHeight + lbl_description.ActualHeight + 40;
this.Height = _height;
rootCanvas.Height = _height;
}
我的控制:
<ListBox x:Name="viewBox"
Visibility="Visible"
Background="{x:Null}"
Foreground="{x:Null}"
Width="580"
Height="580"
BorderThickness="0"
ItemsSource="{Binding Source={StaticResource newsMessages}}"
ItemTemplate="{StaticResource newsTemplate}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemContainerStyle="{StaticResource NoSelectListBoxItemStyle}" />