我不知道爲什麼這個代碼工作正常:列表框裏面的ScrollViewer
<ScrollViewer Height="674" HorizontalAlignment="Left" VerticalAlignment="Top" Width="480" Margin="0,94,0,0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<StackPanel>
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
</StackPanel>
</ScrollViewer>
,這並不:
<ScrollViewer Height="674" HorizontalAlignment="Left" VerticalAlignment="Top" Width="480" Margin="0,94,0,0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ListBox Width="480" ItemsSource="{Binding ViewModel_ObservableCollection_Property_With_15_Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="85">
<Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
一個ListBox的版本是無法顯示在ScrollViewer中的所有項目。有什麼竅門?
歐,是的。我真笨。我沒有意識到這一點。謝謝。 –