假設我想在ListView的一個特定行上顯示信息(在這裏水平顯示,所以它在技術上是列)來模擬日曆般的視覺信息。WPF - 如何明確設置ListView中的項目的索引?
第一行天數(月1日至31日)的列表。
另外兩行是來自兩個不同的CSV導出的數字,我比較了同一天的兩個數字。
我使用第一個ListView保持靜態的日期,並顯示一個整數列表。 我正在使用另一個包含「DayData」模型的ListView。
public class DayData
{
// Top number displayed
public float topNumber { get; set; }
// Bottom number displayed
public float bottomNumber { get; set; }
// Matching day for this entry
public int matchingDay { get; set; }
// Color used to alert user in case of bad ratio
public string color { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="T:System.Object"/> class.
/// </summary>
public DayData()
{
this.topNumber = -1;
this.bottomNumber = -1;
}
}
現在我的問題是,當相比,編號爲空的那一天,我要在列表中顯示「空」的條目,或至少顯示某種利潤率的正確對齊的數字,使在DayData適合他們匹配天數時,就像這樣:
你可能建議增加一個「空」進入名單,但是這會導致性能問題,作爲另一個的ListView承載整個事情,它本身一次顯示幾個ListViews +其他東西的條目。 但是,當我僅顯示DayData條目時沒有任何問題,因爲ListView在一個月內永遠不會包含超過20個。
是否有任何解決方法,就像使用數據模板的網格控件,我可以自己設置行和列並將它們綁定到DayData模型以正確對齊它們?
在此先感謝。
是否有您不使用列的具體原因? – Gusdor
你是什麼意思?我不能使用ListView中的列。沒有任何列的概念,也沒有任何行。只有自動堆疊的「項目」。 –
自己'ListView'的行爲很像一個'Listbox'。但是,您可以通過更改'View'屬性來隨意更改項目的表示形式。開箱即用的實現是'GridView',它可以讓你使用列http://www.wpf-tutorial.com/listview-control/listview-with-gridview/ – Gusdor