0

I'm working on an image gallery as a small project to learn how to program, what I'm trying to get now is to select a directory and all images will be displayed. This is what I have now

.xaml

<Grid x:Name="gridGallery" Height="610.667" Margin="205,70,0,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
     }
}

I don't know if I'm doing anything wrong and don't know what to add after I select the directory, any help would be awesome.

  • It is unclear from your code exactly what is not happening which you think should be happening. What guidance are you exactly seeking? – ΩmegaMan Oct 17 '20 at 00:49
  • Check this link it may help: https://www.codeproject.com/Questions/1237443/Csharp-how-to-sort-images-next-to-each-other-WPF-o – Osama Oct 17 '20 at 09:18

0 Answers0