ListBox コントロールにニュースエリアを表示する Windows 8 アプリを開発しました。ニュース項目については、テンプレートを使用します。ニュース項目にはさまざまなサイズがあります。アイテムのサイズは、LayoutUpdate イベントの後に設定されます。指でリストをスクロールすると、ちらつき効果があります。これらは、後で適応するアイテムの量が原因で発生します。一定のサイズを使用すると、ちらつき効果に問題はありません。マウスでリストをスクロールしても問題ありません。このちらつき効果を好む可能性はありますか? 誰もが同様の問題を抱えていて、私に解決策がありますか?
私のテンプレート:
<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}" />