我在WPF窗口中使用ItemsControl
。 itemscontrol綁定到一個集合,集合是一組視圖模型(用戶控件)。我的問題 - 由於集合中有很多視圖模型,視圖超出了當前窗口。我嘗試了很多事情來處理它與滾動條,但沒有用。有什麼建議麼?真正的問題是如何在窗口中包含itemscontrol(滾動)?ItemsControl-包裝窗口內的內容
的XAML下面
<Window x:Class="WpfApplicationTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:app="clr-namespace:WpfApplicationTest"
Title="MainWindow" Height="350" Width="525">
<Grid Height="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ItemsControl Grid.Row="0" Grid.Column="0" ItemsSource="{Binding UserControlCollection}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Bottom">
<Button Content="OK" Width="100" Margin="3" />
<Button Content="Cancel" Width="100" Margin="3" />
</StackPanel>
</Grid>
嗯,我做到了,但滾動查看器本身超出了窗口,我無法滾動 – Jimmy 2011-03-22 16:26:32