In WPF you can use an IValueConverter or IMultiValueConverter to convert a data-bound value from say an int
to a Color.
I have a collection of Model objects which I would like to convert to their ViewModel representations but in this scenario,
<ListBox ItemsSource="{Binding ModelItems,
Converter={StaticResource ModelToViewModelConverter}" />
the converter would be written to convert the whole collection ModelItems
at once.
I wish to convert the items of the collection individually, is there a way to do that? I might want to use a CollectionViewSource
and have some filtering logic so I don't want to have to iterate over the whole collection every time something changes.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…