Niestety nie za bardzo rozumiem jak mam podpiąć obiekt danej klasy jako źródło danych w tabelce. W Przykladzie jest linijka
<DataGrid ItemsSource="{Binding Customers}" />
Ja jako źródło chciałbym podpiąć klasę z projektu o nazwie DataAttributeCollection która dziedziczy po liście a jej elementami są obiekty klasy DataAttribute który zawiera nazwę jako string i listę swoich wartości jako stringi. Chciałbym, aby w pierwszej kolumnie wyświetlała się nazwa atrybutu a w pozostałych x kolumnach jej wartości.
//edit
Napisałem takie coś
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Decision_tree.DataObjects.DataAttributes;
namespace Decision_tree.Views.Pages
{
/// <summary>
/// </summary>
public partial class PageAttributeData : Window
{
public PageAttributeData()
{
DataAttributeCollection dac = new DataAttributeCollection();
DataAttribute da = new DataAttribute("Wind");
da.AddValue("Weak");
da.AddValue("Strong");
da.AddValue("Medium");
dac.Add(da);
da = new DataAttribute("Temperature");
da.AddValue("Low");
da.AddValue("Medium");
da.AddValue("High");
dac.Add(da);
AttributeDataGrid.ItemsSource = dac;
InitializeComponent();
}
}
}
Poprawnie to napisałem? Jeśli tak to jak teraz te wszystkie dane i zaprezentować je w tabeli?
//edit2
No jednak się przekonałem, że źle napisałem.
System.NullReferenceException: „Object reference not set to an instance of an object.”