情況是這樣的:空LongListSelector引起無限的ScrollViewer
我有被某些屬性過濾數據源(可以稱之爲經過),到對視圖模型兩個列表。稱它爲新的和舊的。
新的需要顯示在一個列表中,舊的需要顯示在它下面的列表中。
哦,他們需要一致滾動。因此,如果Old目前不在屏幕上,那麼當清單被刷新時,它會游到可見性中。一個ScrollViewer中內一個StackPanel內
<ScrollViewer VerticalAlignment="Top" VerticalScrollBarVisibility="Auto">
<StackPanel>
<phone:LongListSelector x:Name="NewList" Margin="0,0,0,0" ItemsSource="{Binding New}" SelectionChanged="NewList_SelectionChanged">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17">
<TextBlock Text="{Binding Name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" Foreground="{Binding Color}" />
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
<phone:LongListSelector x:Name="OldList" Margin="0,0,0,0" ItemsSource="{Binding Path=Old}" Padding="0,20,0,0">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17">
<TextBlock Text="{Binding Name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" FontStyle="Italic" Foreground="{Binding Color}"/>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</StackPanel>
</ScrollViewer>
兩個longlistselectors:
我已經與LongListSelectors目前解決了這個這樣的。現在,這一切都是絕對的fab,而這兩個列表中都有一些東西。
但是,當其中一個沒有任何內容時,它會立即擴展以填充其父項的整個高度。在這種情況下......無限的scrollviewer。這意味着,如果新列表中沒有任何內容,屏幕上絕對不會顯示任何內容,並且如果新列表中沒有任何內容......我可以在通過新列表項目後無限滾動。
我在這裏有什麼選擇嗎?沒有以編程方式創建大量的文本字段,然後試圖附加事件,或者更糟糕的是,寫我自己的列表控件?標準列表框不起作用,因爲它們都單獨滾動。
任何想法?
手機沒有MaxHeight屬性嗎?我知道有時候這對WPF來說有點蹩腳的解決方案,但它確實有效! – Hannish
有。問題是,我可能向下滾動得太遠,或者不能充分展開。 – NeroS
我也有類似的問題。你能否嘗試移除你明確定義的Scrollviewer,並使用默認的ItemSelector滾動。 –