第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

虛擬化ItemsControl?

虛擬化ItemsControl?

虛擬化ItemsControl?我有一個(gè)ItemsControl但是,它包含了我想要虛擬化的數(shù)據(jù)列表。VirtualizingStackPanel.IsVirtualizing="True"似乎不適用于ItemsControl.這是真的嗎?還是有其他我不知道的方法?為了進(jìn)行測(cè)試,我使用了以下代碼塊:<ItemsControl ItemsSource="{Binding Path=AccountViews.Tables[0]}"               VirtualizingStackPanel.IsVirtualizing="True"><ItemsControl.ItemTemplate>     <DataTemplate>         <TextBlock Initialized="TextBlock_Initialized"                      Margin="5,50,5,50" Text="{Binding Path=Name}" />     </DataTemplate></ItemsControl.ItemTemplate></ItemsControl>如果我更改ItemsControl轉(zhuǎn)到ListBox,我可以看到Initialized事件只運(yùn)行幾次(巨大的邊距,所以我只需要看幾個(gè)記錄),但是作為一個(gè)ItemsControl每個(gè)項(xiàng)目都會(huì)被初始化。我試過(guò)設(shè)置ItemsControlPanelTemplate轉(zhuǎn)到VirtualizingStackPanel但這似乎沒(méi)什么用。
查看完整描述

3 回答

?
守候你守候我

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超10個(gè)贊

其實(shí)不僅僅是ItemsPanelTemplate使用VirtualizingStackPanel..默認(rèn)ControlTemplateItemsControl沒(méi)有ScrollViewer,這是虛擬化的關(guān)鍵。添加到默認(rèn)控件模板中。ItemsControl(使用控件模板ListBox作為模板)給我們提供了以下內(nèi)容:

<ItemsControl
????VirtualizingStackPanel.IsVirtualizing="True"
????ScrollViewer.CanContentScroll="True"
????ItemsSource="{Binding?Path=AccountViews.Tables[0]}">
????<ItemsControl.ItemTemplate>
????????<DataTemplate>
????????????<TextBlock
????????????????Initialized="TextBlock_Initialized"
????????????????Text="{Binding?Path=Name}"?/>
????????</DataTemplate>
????</ItemsControl.ItemTemplate>
????<ItemsControl.ItemsPanel>
????????<ItemsPanelTemplate>
????????????<VirtualizingStackPanel?/>
????????</ItemsPanelTemplate>
????</ItemsControl.ItemsPanel>
????<ItemsControl.Template>
????????<ControlTemplate>
????????<Border
????????????BorderThickness="{TemplateBinding?Border.BorderThickness}"
????????????Padding="{TemplateBinding?Control.Padding}"
????????????BorderBrush="{TemplateBinding?Border.BorderBrush}"
????????????Background="{TemplateBinding?Panel.Background}"
????????????SnapsToDevicePixels="True">
????????????????<ScrollViewer
????????????????????Padding="{TemplateBinding?Control.Padding}"
????????????????????Focusable="False">
????????????????????<ItemsPresenter
????????????????????????SnapsToDevicePixels="{TemplateBinding?UIElement.SnapsToDevicePixels}"?/>
????????????????</ScrollViewer>
????????????</Border>
????????????</ControlTemplate>
????</ItemsControl.Template></ItemsControl>


查看完整回答
反對(duì) 回復(fù) 2019-06-23
?
慕雪6442864

TA貢獻(xiàn)1812條經(jīng)驗(yàn) 獲得超5個(gè)贊

在DavidN的回答的基礎(chǔ)上,您可以在ItemsControl上使用一種樣式來(lái)虛擬化它:

<!--Virtualised ItemsControl--><Style x:Key="ItemsControlVirtualizedStyle" TargetType="ItemsControl">
    <Setter Property="VirtualizingStackPanel.IsVirtualizing" Value="True"/>
    <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
    <Setter Property="ItemsPanel">
        <Setter.Value>
            <ItemsPanelTemplate>
                <VirtualizingStackPanel />
            </ItemsPanelTemplate>
        </Setter.Value>
    </Setter>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ItemsControl">
                <Border
                    BorderThickness="{TemplateBinding Border.BorderThickness}"
                    Padding="{TemplateBinding Control.Padding}"
                    BorderBrush="{TemplateBinding Border.BorderBrush}"
                    Background="{TemplateBinding Panel.Background}"
                    SnapsToDevicePixels="True"
                >
                    <ScrollViewer Padding="{TemplateBinding Control.Padding}" Focusable="False">
                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                    </ScrollViewer>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter></Style>

我不喜歡使用ListBox的建議,因?yàn)樗鼈冊(cè)试S選擇不一定需要的行。


查看完整回答
反對(duì) 回復(fù) 2019-06-23
?
12345678_0001

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超5個(gè)贊

只是默認(rèn)的ItemsPanel不是VirtualizingStackPanel..你需要改變它:

<ItemsControl>
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <VirtualizingStackPanel />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel></ItemsControl>


查看完整回答
反對(duì) 回復(fù) 2019-06-23
  • 3 回答
  • 0 關(guān)注
  • 732 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)