微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

显示所选目录中的照片

如何解决显示所选目录中的照片

我正在将图片画廊作为一个小项目来学习如何编程,我现在想要获取的是选择一个目录,所有图片都会显示出来。这就是我现在拥有的

.xaml

<Grid x:Name="gridgallery" Height="610.667" Margin="205,70,0" Width="1058.338">
     <ListBox x:Name="listBoxgallery">
          <ListBox.ItemTemplate>
               <DataTemplate>
                    <StackPanel Orientation="Vertical">
                         <Image Margin="5" Source="{Binding Path}" Height="150" Stretch="Uniform"/>
                         <TextBlock Margin="5" Text="{Binding Name}"/>
                    </StackPanel>
               </DataTemplate>
          </ListBox.ItemTemplate>
     </ListBox>
</Grid>

.xaml.cs

private void ButtonDirectory_Click(object sender,RoutedEventArgs e)
{
     var dialog = new CommonopenFileDialog
     {
          DefaultDirectory = "Photos",IsFolderPicker = true
     };
     if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
     {
          //adds all photos in the selected folder to gallery
     }
}

我不知道我做错了什么,也不知道选择目录后要添加什么,任何帮助都很棒。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。