I need to inherit my Collection as Class as follows:
public class UsageCollection
: ObservableCollection<UsageStatistics>
{
public UsageCollection()
{
// static initialization
Add(new UsageStatistics("A", 6, "1/2/2012"));
Add(new UsageStatistics("C", 8, "1/2/2012"));
}
}
public class UsageStatistics
{
public string Alias { get; set; }
public int ActivityCount { get; set; }
public string Date { get; set; }
public UsageStatistics(
string alias,
int activityCount,
string date
)
{
Alias = alias;
ActivityCount = activityCount;
Date = date;
}
}
As you can see I can statically initialize it in the constructor.
However , I am fetching this collection at runtime in reality. How can I assign that collection to this class?
The collection im fetching is ObservableCollection<UsageStatisctics>
.
The reason I need to encapsulate is because infragistics needs this:
<Window.Resources>
<comboSourceCase:UsageCollection x:Key="data" />
<ig:GroupBy
x:Key="grouped"
ItemsSource="{StaticResource data}"
GroupMemberPath="Date"
KeyMemberPath="Alias"
ValueMemberPath="ActivityCount" />
</Window.Resources>
<Grid Margin="0,0,2,-2">
<ig:XamDataChart x:Name="theChart" Height="200">
<ig:XamDataChart.Axes>
<ig:CategoryXAxis x:Name="xAxis"
ItemsSource="{StaticResource grouped}"
Label="{}{Key}"/>
<ig:NumericYAxis x:Name="yAxis" />
</ig:XamDataChart.Axes>
<ig:XamDataChart.Series>
<ig:StackedColumnSeries x:Name="stack"
ItemsSource="{StaticResource grouped}"
XAxis="{Binding ElementName=xAxis}"
YAxis="{Binding ElementName=yAxis}"
AutoGenerateSeries="True"
>
</ig:StackedColumnSeries>
</ig:XamDataChart.Series>
</ig:XamDataChart>
Please suggest how I can add the collection I got to the UsageCollection
class, or an alternative for how to use it.