When Collection Propert Repesents History, What Binding Strategy for the most Recent Item?
I have an entity in EF4 that represents a device in the field being tested (Device). This entity has a property called DeviceStatuses with three fields (key1, key2, datetime). It is a bridge table to the Status table. It is used to keep a hist开发者_开发问答ory of the statuses an individual device has been set to. So the navigation property Device.DeviceStatuses.Status Gives me a collection of DeviceStatuses but only the DeviceStatus with max(datetime) is the one I am interested in.
My question is how would I go about working with this? Could I create a custom Property in the Device entity? Is there a way in the XAML of my application to bind only to the status I want?
Because of the type of collection returned I was not able to use the {Binding Device.DeviceStatuses[0].Status}
syntax. I ended up writing a custom converter that grabbed the most recent value and returned said value.
精彩评论