I have a list of objects I'm returning from a database. Should I be loading them into two lists - one an observablecollection with the fields that I want to display, and another with all the other fields that won't be shown. Or can I just load everything into the ObservableCollection, and simply not raise a PropertyChanged event on the properties that won't be displayed?
(BTW: I'm way to new at WPF to be implementing the MVVM pattern, so any MVVM based comments will likely be wasted on me).
Can I be lazy and do this?
{
var Foos = new ObservableCollection<Foo>();
}
class Foo
{
public int FooID { get; set;}
private string _fooName;
public string FooName
{
get
{
return _fooName;
}
set
{
if (_fooName != value)
{
_fooName = value;
OnPropertyChanged();
}
}
}
}
Or should I repeat myself for the sake of binding performance and do this?
{
var foos = new List<Foo>();
var FoosToDisplay = new ObservableCollection<FooToDisplay>();
}
class Foo
{
public int FooID { get; set;}
public string FooName { get; set; }
}
class FooToDisplay
{
private string _fooName;
public string FooName
{
get
{
return _fooName;
}
set
{
if (_fooName != value)
{
_fooName = value;
OnPropertyChanged();
}
}
}
}
Or can FooToDisplay inherit from Foo?
What I have tried:
Haven't tried anything. Need advice before I start.