For example, I have this class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Text.RegularExpressions;
namespace GameLenseWpf.Entities
{
public class Game
{
public Game()
{
IsValid = true;
}
//Property used to verify if the model is valid.
public bool IsValid { get; set; }
private string _releaseDate;
public string ReleaseDate
{
get { return _releaseDate; }
set
{
_releaseDate = Regex.Replace(value, @"\s+", " ").Trim();
}
}
private string _pageUrl;
public string PageUrl
{
get { return _pageUrl; }
set
{
Uri uri;
if (Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out uri))
{
_pageUrl = uri.ToString();
}
else
{
IsValid = false;
}
}
}
private string _imageUrl;
public string ImageUrl
{
get
{
return _imageUrl;
}
set
{
Uri uri;
if (Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out uri))
{
_imageUrl = uri.ToString();
}
else
{
IsValid = false;
}
}
}
private string _title;
public string Title
{
get
{
return _title;
}
set
{
if (value.Length > 25)
_title = value.Substring(0, 25) + "...";
else
_title = value;
}
}
private string _synopsis;
public string Synopsis
{
get
{
return _synopsis;
}
set
{
_synopsis = HttpUtility.HtmlDecode(value);
}
}
}
}
And here’s my XAML:
<ListView Grid.Row="1" Background="#343434">
</ListView>
How would I define a layout of the contents in this ListView? I’m porting a working Windows Forms application to WPF. In my Winforms, I have a UserControl that would display this information from my POCO, and I would add N amount of UserControls to a Panel.
Thanks for the suggestions.
This should be a good start:
You can assign
listView1.ItemsSourcein the code.