In Xaml, suppose I have a CollectionViewSource who's source is set to observable collection of objects of type Order:
public class Order
{
public int ContractID
{
get;
set;
}
public double? Price
{
get;
set;
}
public OrderSide Side
{
get;
set;
}
}
public enum OrderSide
{
BID,
ASK
}
A Bid order is an order who's Side property is BID, ask is ASK. The problem is that I need the orders to be displayed in the current format
Grouped by ContractID
Bids (Descending) Asks (Ascending)
More specifically, the problem is that I need the Bids and Asks to be displayed side by side.
So, for example with the following collection,
var orders = new List<Order>()
{
new Order(){ContractID=1,Price=10,Side=OrderSide.BID},
new Order(){ContractID=1,Price=11,Side=OrderSide.ASK},
new Order(){ContractID=1,Price=9,Side=OrderSide.BID},
new Order(){ContractID=1,Price=11.5,Side=OrderSide.ASK},
new Order(){ContractID=2,Price=20,Side=OrderSide.BID},
new Order(){ContractID=2,Price=24,Side=OrderSide.ASK},
new Order(){ContractID=2,Price=21,Side=OrderSide.BID}
};
It would be rendered as
1
10 11
9 11.5
2
21 24
20
I'm guessing i need to use a combination of a filtered CollectionViewSource and datatemplateselectors..?
As an added bonus, i'd like to be able to display the best bid and best ask on the grouping row. So, using the same data, it'd be rendered as
1 10 11
10 11
9 11.5
2 21 24
21 24
20
Any help much appreciated -