0

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

誰が私が間違ったことを教えてもらえますか?

4

1 に答える 1