How do I develop an algorithm?

Need simple help to develop c# algorithm

  • I'm using WPF. On my window there is a data grid which binding with observable collection. This collection contains data about room check outs. So there is also one window which must add service collection to data grid >> create new collection with name of service an fill cell with price. This price must be set on row where id(column) == "example". I think it must be very easy but I'm trying this 2 days.. so my question : is it possible to bind data grid with two collections? How I can add collection new property ? Like that : public string ServiceName{get;set;} from another window. Please advice some good thing how to solve this problem

  • Answer:

    To bind to multiple collections use the CompositeCollection. Here's a ListBox example: <ListBox Name="myListBox" Height="300" Width="200" Background="White"> <ListBox.ItemsSource> <CompositeCollection> <CollectionContainer Collection="{Binding Source={StaticResource GreekGodsData}}" /> <CollectionContainer Collection="{Binding Source={StaticResource GreekHeroesData}}" /> <ListBoxItem Foreground="Red">Other Listbox Item 1</ListBoxItem> <ListBoxItem Foreground="Red">Other Listbox Item 2</ListBoxItem> </CompositeCollection> </ListBox.ItemsSource> </ListBox> This example and more info can be found on MSDN: http://msdn.microsoft.com/en-us/library/system.windows.data.compositecollection.aspx. Another important point to mention is CompositeCollection does not implement IEditableCollectionView so if you need to edit the datagrid, you cannot use CompositeCollection without implementing IEditableCollectionView yourself.

Acid at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

No you can't bind a property to two things at the same time. Normaly you would aggregate the two data-objects into a single Helperobject and use those in the observable-collection.

Carsten König

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.