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.