0
我想給folder path
並從該文件夾的路徑如果folder contains 3 images
我想display those 3 images
爲StackPanel WPF Form
如何從文件夾中添加StackPanel WPF中的多個圖像?
我試過類似下面的正常工作爲一個圖像,而是如何能夠加載所有從給定文件夾中的圖片?
<Window x:Class="wpfBug.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300" Loaded="Window_Loaded">
<StackPanel Name="sp">
</StackPanel>
</Window>
private void Window_Loaded(object sender, RoutedEventArgs e)
{
Image i = new Image();
BitmapImage src = new BitmapImage();
src.BeginInit();
src.UriSource = new Uri("mypic.png", UriKind.Relative);
// how to load all images from given folder?
src.EndInit();
i.Source = src;
i.Stretch = Stretch.Uniform;
//int q = src.PixelHeight; // Image loads here
sp.Children.Add(i);
}
我認爲所有的圖像都彼此loasing :( 我怎樣才能使一個空間兩個圖像之間 – Neo
設置其保證金的財產? 。 – Clemens
仍然只顯示一個圖像:O奇怪我已經寫了'imageItems.ItemsSource = Directory.EnumerateFiles(FOLDERPATH,「* .png」);'on'Window_Loaded' – Neo