例如,我有這個類:如何定義進入ListView的內容?
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);
}
}
}
}
這是我的XAML:
<ListView Grid.Row="1" Background="#343434">
</ListView>
我怎麼會在這的ListView定義內容的佈局?我正在將一個工作的Windows Forms應用程序移植到WPF。在我的Winforms中,我有一個UserControl可以顯示來自我的POCO的這些信息,並且我會將N個用戶控件添加到Panel中。
感謝您的建議。
謝謝!現在這個工作已經足夠好了,我可能會學習一些先進的技術。 – 2011-05-14 22:56:49