我有一个滚动查看器,我想显示我的所有用户控件。我有两种类型的用户控件,即教育和工作。它们只是文本框和按钮。我动态地创建各种数量的每个并将它们添加到类型 usercontrol 的列表中。但是我无法显示所有用户控件!
滚动查看器 xaml
<ScrollViewer x:Name="myScrollViewer" HorizontalAlignment="Left" Height="518" Margin="128,10,0,0" Grid.Row="1" VerticalAlignment="Top" Width="1123" FontSize="22"/>
背后的代码
List<UserControl> info = new List<UserControl>();
EducationControl educationControl = new EducationControl(school._school, school._degree, school._fieldOfStudy, school._educationStartDate, school._educationEndDate);
info.Add(educationControl);
WorkControl workControl = new WorkControl(work._employer, work._jobTitle, work._jobStartDate, work._jobEndDate);
info.Add(workControl);
myScrollViewer.Content = info;
当我将滚动查看器的内容设置为信息时,它只显示一个字符串,如: System.Collections.Generic.list'1[Windows.UI.Xaml.Controls.UserControl]
但是,当我这样做时,我可以让一个单独的用户控件正确显示:
myScrollViewer.Content = info.ElementAt(0);
如何在滚动查看器中显示所有用户控件?