1
私はスクロールビューアでグリッドを使用しています。そのグリッドは、UI要素の数を増やして設計しました。そのレポートを開くと、パフォーマンスの問題で最初のページのUI要素のみがレンダリングされました。スクロール中に残りのUI要素をレンダリングする必要があります。スクロール中にテンプレートが適用されない
スクロールスクロールビューアテンプレートが残りの要素の秒間印加されていませんが私の質問は、
です。 しかし、最初のページのUI要素はテンプレートで正しく更新されます。
なぜスクロールを実行するのですか?テンプレートは1秒間適用されません。
XAMLファイルのコードスニペット:背後
<ScrollViewer Grid.Row="1" Focusable="False" ScrollChanged="DesignScrollViewer_ScrollChanged" x:Name="DesignScrollViewer" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<ScrollViewer.Template>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<Grid x:Name="Grid" Background="#FFF9F9F9">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="0" />
</Grid.RowDefinitions>
<Grid AllowDrop="True" Grid.Column="0" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Background="#ffffffff" BorderBrush="#ffbbbbbb" Visibility="Collapsed" BorderThickness="0,1,1,0" Grid.Column="1">
<StackPanel Orientation="Horizontal">
<ToggleButton Width="16" ToolTip="Layout" x:Name="AutoFit" Grid.Column="0" Style="{StaticResource ToggleButtonStyle}" Click="AutoFit_Click_1" VerticalAlignment="Stretch" Margin="0" Height="12">
<Path x:Name="fittoscreen" Data="M8.84896,6.54523 L10.66668,6.54523 10.66668,10.666019 6.5462299,10.666019 6.5462299,8.847971 8.84896,8.847971 z M0,6.54523 L1.8183599,6.54523 1.8183599,8.8479717 4.12177,8.8479717 4.12177,10.66602 0,10.66602 z M6.5462299,0 L10.66668,0 10.66668,4.1210899 8.84896,4.1210899 8.84896,1.8183599 6.5462299,1.8183599 z M0,0 L4.12177,0 4.12177,1.8183599 1.8183601,1.8183599 1.8183601,4.1210899 0,4.1210899 z" Fill="#FF646464" Height="8" Stretch="Fill" Width="8" />
</ToggleButton>
<ComboBox Margin="0" ItemContainerStyle="{StaticResource ZoomComboboxItem}" AllowDrop="True" SelectedIndex="-1" Style="{StaticResource ZoomComboBoxStyle}" IsEditable="True" VerticalAlignment="Stretch" Height="12" FontSize="10" Tag="AtStart" PreviewKeyDown="cmboSearchField_PreviewKeyDown" BorderThickness="0" x:Name="cmboSearchField" Width="50" KeyDown="cmboSearchField_KeyDown_1" SelectionChanged="cmboSearchField_SelectionChanged_1" IsTextSearchEnabled="false" />
<ComboBoxItem FontSize="10" x:Name="Item1" Content="20 %" />
<ComboBoxItem FontSize="10" x:Name="Item2" Content="50 %" />
<ComboBoxItem FontSize="10" x:Name="Item3" Content="70 %" />
<ComboBoxItem FontSize="10" x:Name="Item4" Content="100 %" />
<ComboBoxItem FontSize="10" x:Name="Item5" Content="150 %" />
<ComboBoxItem FontSize="10" x:Name="Item6" Content="200 %" />
<ComboBoxItem FontSize="10" x:Name="Item7" Content="400 %" />
</ComboBox>
</StackPanel>
</Border>
<Border Background="#FFFFFFFF" VerticalAlignment="Bottom" BorderBrush="#FFBBBBBB" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" BorderThickness="0,1,1,0" Grid.Column="0">
<ScrollBar HorizontalAlignment="Stretch" BorderThickness="0" AllowDrop="True" x:Name="PART_HorizontalScrollBar" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}" Margin="0,-1" Height="16" />
</Border>
</Grid>
<!--<Rectangle x:Name="Corner" Grid.Column="" Fill="Transparent" Grid.Row="1" />-->
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Grid.Row="0"/>
<Border x:Name="ContentScroll" BorderThickness="0" Background="#FFF9F9F9" HorizontalAlignment="Right" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" BorderBrush="#FFBBBBBB" Grid.Column="1">
<ScrollBar HorizontalAlignment="Right" HorizontalContentAlignment="Center" x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" />
</Border>
</Grid>
</ControlTemplate>
</ScrollViewer.Template>
<Grid Focusable="False" VerticalAlignment="Center" HorizontalAlignment="Center">
<!--<Grid.RowDefinitions>
<RowDefinition x:Name="FilterZoneRow" Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>-->
<!--<Grid x:Name="FilterZone" Margin="0,0,0,5" Background="#FF1A1A1A" Visibility="Collapsed">
<Grid x:Name="FilterGrid">
<designLayout:GridCanvas x:Name="FZoneCanvas" KeyboardNavigation.IsTabStop="False" RowCount="0" IsInDesignMode="True" CanvasLayout="DesktopFreeForm" FreeFormSize="Small" Transform="{Binding ElementName=Canvas,Path=Transform,Mode=TwoWay}" ShowGridLines="{Binding Path=ShowGridLines,ElementName=Canvas}" Background="#FF1A1A1A">
</designLayout:GridCanvas>
<Canvas>
<Border x:Name="FilterControlPlacementBorder" Visibility="Collapsed" BorderBrush="Red" BorderThickness="1">
</Border>
<Button x:Name="FilterControlPlacementContent" KeyboardNavigation.IsTabStop="False" Visibility="Collapsed" IsHitTestVisible="False" BorderBrush="{x:Null}" VerticalAlignment="Center" HorizontalAlignment="Center" />
<Rectangle StrokeDashArray="4 2" x:Name="SelectionFRect" Visibility="Collapsed" Stroke="Gray" StrokeThickness="1.5" />
</Canvas>
</Grid>
<Border x:Name="FilterZoneBorder" BorderBrush="Yellow" AllowDrop="False" Visibility="Collapsed" BorderThickness="1" />
</Grid>-->
<Grid Grid.Row="0" Focusable="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" FocusVisualStyle="{x:Null}" x:Name="CanvasGrid">
<Border BorderBrush="Transparent" BorderThickness="0" Background="Transparent">
<Border.Effect>
<DropShadowEffect ShadowDepth="0" BlurRadius="5" Opacity="0.3" Color="Black" />
</Border.Effect>
</Border>
<designLayout:GridCanvas KeyboardNavigation.IsTabStop="True" KeyboardNavigation.TabNavigation="Once" FocusVisualStyle="{x:Null}" Background="Transparent" x:Name="Canvas" CanvasLayout="DesktopGridCanvas" VerticalAlignment="Center" HorizontalAlignment="Center" ClipToBounds="True" Focusable="True" ShowGridLines="True" IsInDesignMode="True">
</designLayout:GridCanvas>
<Canvas>
<Border x:Name="ControlPlacementBorder" Visibility="Collapsed" BorderThickness="1">
<!--<Button x:Name="ControlPlacementContent" IsHitTestVisible="False" BorderBrush="{x:Null}" VerticalAlignment="Center" HorizontalAlignment="Center" />-->
</Border>
</Canvas>
</Grid>
</Grid>
</ScrollViewer>
コード:事前に
private void DesignScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (e.VerticalOffset > OffsetValue)
{
OffsetValue = e.VerticalOffset;
if (TempCanvasRowCount < DesignCanvas.RowCount &&(e.VerticalOffset/48) > prevCanvasRowCount)
{
TempCanvasRowCount += 12;
prevCanvasRowCount += 12;
RenderingElements();
if (TempCanvasRowCount > DesignCanvas.RowCount)
TempCanvasRowCount = DesignCanvas.RowCount;
}
}
}
感謝。
お客様の問題に該当するコードスニペットを入力してください。 –
XAMLまたは関連コードを表示してください。 –
グリッド内またはスクロールビューア内で仮想化を使用していますか? – user2250152