Jim*_*mmy 2 wpf user-controls itemscontrol mvvm itemsource
我ItemsControl
在WPF中使用了一个窗口.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>
Run Code Online (Sandbox Code Playgroud)