1

我正在动态填充一个充满 HubTile 项目的列表框,但该列表不会在模拟器或我的设备上向下滚动。我在后面的代码中创建的列表(绑定到列表框)仅包含 28 个项目。我不确定问题是什么,似乎一切都加载得相当快。我所拥有的如下:

主页.xaml

<ScrollViewer>

                    <ListBox Grid.Row="0" x:Name="connectionTileList" Margin="12,0,12,0" toolkit:TiltEffect.IsTiltEnabled="True">
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <toolkit:WrapPanel Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <toolkit:HubTile Title="{Binding TileName}" Margin="6"
                                         Notification="{Binding Notification}"
                                         DisplayNotification="{Binding DisplayNotification}"
                                         Message="{Binding Message}"
                                         GroupTag="{Binding GroupTag}"
                                         Source="{Binding ImageUri}"
                                         Tap="connectionHubTile_Tap">
                                    <toolkit:ContextMenuService.ContextMenu>
                                        <toolkit:ContextMenu x:Name="connectionMenu">
                                            <toolkit:MenuItem Header="pin to start" Tap="connectionMenuItem_Tap"/>
                                        </toolkit:ContextMenu>
                                    </toolkit:ContextMenuService.ContextMenu>
                                </toolkit:HubTile>

                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                </ScrollViewer>

MainPage.xaml.cs

List<TileItem> networkTileItems;

public MainPage()
    {
        InitializeComponent();

        CreateConnectionHubTiles();
    }

private void CreateConnectionHubTiles()
    {
        networkTileItems = new List<TileItem>
        {

            new TileItem() { ImageUri = "/Images/Network/temp.png", Title = "Asymmetric DSL", Notification = "not active (what is proper term?)", /*Message = "not active (what is proper term?)"*/ GroupTag = "ConnectionTileGroup", TileName = "Asymmetric DSL", Type = NetworkInterfaceType.AsymmetricDsl  },
                ...

        };

        this.connectionTileList.ItemsSource = networkTileItems;
    }

运行时,无论我尝试向上还是向下滚动,列表都只会创建向上滚动的效果。我怎样才能解决这个问题?我应该在后台线程中加载图像,还是在滚动时一次只加载几张图像,或者其他什么?如果是这样,我怎么能做到这一点?

4

1 回答 1

0

这里的问题是您将 a 包装ListBox在 a 中ScrollViewer,并且两个控件都在尝试进行操作。无论设置

ScrollViewer.VerticalScrollBarVisibility="Disabled"ListBox, 让外部ScrollViewer管理滚动,或ScrollViewer完全删除外部。

于 2012-08-19T19:03:23.310 回答