我在 XAML 中有如下定义的 WrapPanel ...
<Page x:Class="SelectImages"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="320" d:DesignWidth="480"
Title="Select Images">
<Grid>
<WrapPanel Name="MyImagePanel" Width="Auto" Height="Auto" Margin="10,50,10,10" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" Orientation="Horizontal">
</WrapPanel>
</Grid>
</Page>
当我尝试在后面的代码中使用 WrapPanel 时,出现运行时错误“对象引用未设置为对象实例”。
Private Sub AddImageToPanel(Image As FileSystemInfo)
MyImagePanel.Children.Add(NewPicture(Image))
End Sub
谁能告诉我我做错了什么?