I am trying to get images from folder and store them into a class name 'Project'.
Then I want to display them in listview.
So I could show list of images in each project class with project name at above.
This is 'Project' class.
public class Project : INotifyPropertyChanged
{
private int id { get; set; }
private string name { get; set; }
private bool isChecked;
public int ProjectId
{
get { return id; }
set
{
id = value;
NotifyPropertyChanged();
}
}
public string ProjectName
{
get { return name; }
set
{
name = value;
NotifyPropertyChanged();
}
}
public bool IsChecked
{
get { return isChecked; }
set
{
isChecked = value;
NotifyPropertyChanged();
}
}
public List<string> projectImages { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
This is function which add images into list.
private void menu_Open_Project(object sender, RoutedEventArgs e)
{
var imageList = GetImageFromDirectory.GetImageFiles(some directory path goes here);
if (projects.Count > 0)
{
var lastIndexNumber = projects.Last().ProjectId + 1;
projects.Add(new Project() { ProjectId = lastIndexNumber, ProjectName = "Project " + lastIndexNumber.ToString(), projectImages = imageList });
}
}
This is the xaml with list view
<ListView Name="projectListView" Background="LightGray">
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource HeaderStyle}">
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<Border BorderBrush="Black" BorderThickness="2, 2, 2, 2">
<Grid>
<TextBlock Text="{Binding ProjectName}" Background="Gray"/>
</Grid>
</Border>
<Border BorderBrush="Black" BorderThickness="2, 0, 2, 2">
<Grid>
<Image/>
</Grid>
</Border>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>