问题描述
我正在将图片画廊作为一个小项目来学习如何编程,我现在想要获取的是选择一个目录,所有图片都会显示出来。这就是我现在拥有的
.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 (将#修改为@)