Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Displaying images on ListBox in WPF

$
0
0

I spent a lot of time on try code I found on various pages on web but nothing works for me
In my app, the user load image and I do few image processor on it.
finally, I want to show "a bar" for the user, should contain all the images after the processing (I saved the images, so I can use image path).

XAML (it base on this code):

<Window.Resources><DataTemplate x:Key="ImageGalleryDataTemplate"><Grid><Border BorderBrush="#FFFF9800" BorderThickness="1"  Width="120" Height="120" Padding="5" Margin="5" CornerRadius="6"><!--Bind Image Path in Image Control--><Image Source="{Binding ImagePath}" Stretch="Fill"  HorizontalAlignment="Center"><!--View Large Image on Image Control Tooltip--><Image.ToolTip><Grid><Image Source="{Binding ImagePath}" Stretch="Fill" HorizontalAlignment="Center" Height="200" Width="200"></Image></Grid></Image.ToolTip></Image></Border></Grid></DataTemplate><ItemsPanelTemplate x:Key="ImageGalleryItemsPanelTemplate"><!--Display Images on UniformGrid Panel--><UniformGrid Rows="1" Columns="25" HorizontalAlignment="Center" VerticalAlignment="Stretch"/></ItemsPanelTemplate></Window.Resources><!-- The ListBox --><Grid Grid.Column="1" Height="164" HorizontalAlignment="Left" Margin="0,707,0,0" Name="grid1" VerticalAlignment="Top" Width="1232"><ListBox Canvas.Left="-4" Canvas.Top="0" Height="160" Name="lb_Images" Width="1236" Background="{x:Null}"
	ItemsSource="{Binding}" ItemTemplate="{DynamicResource ImageGalleryDataTemplate}"
        ItemsPanel="{DynamicResource ImageGalleryItemsPanelTemplate}"
	HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" BorderBrush="{x:Null}" /></Grid>



Code:

public MainWindow()
{
    lb_Images.DataContext = ImagePath;
}

Edit:

I update the list (ImagePath) with image path every time I receive image from the camera.

Thanks, for any help





Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>