It is like @venerik said - CompositeCollection
is not available on Windows Phone.
But my proposal is to write your own Composite class. I've managed to build a simple example:
In XAML: - simple ListBox (of course it can be LLS)
<Grid x:Name="LayoutRoot" Background="Transparent">
<ListBox Name="myList" >
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
In code behind: - custom class
public class myComposite<T> : ICollection<T>
{
ObservableCollection<T> firstCollection;
ObservableCollection<T> secondCollection;
public myComposite(ObservableCollection<T> first, ObservableCollection<T> second)
{
firstCollection = first;
secondCollection = second;
}
IEnumerator IEnumerable.GetEnumerator() { return new myEnum<T>(this); }
public IEnumerator<T> GetEnumerator() { return new myEnum<T>(this); }
public int Count { get { return firstCollection.Count + secondCollection.Count; } }
public T this[int i]
{
get
{
if (i <= firstCollection.Count - 1) return firstCollection[i];
else return secondCollection[i - firstCollection.Count];
}
set
{
if (i <= firstCollection.Count - 1) firstCollection[i] = value;
else secondCollection[i - firstCollection.Count - 1] = value;
}
}
public void Add(T item) { throw new NotImplementedException(); }
public void Clear() { throw new NotImplementedException(); }
public bool Contains(T item) { throw new NotImplementedException(); }
public void CopyTo(T[] array, int arrayIndex) { throw new NotImplementedException(); }
public bool IsReadOnly { get { throw new NotImplementedException(); } }
public bool Remove(T item) { throw new NotImplementedException(); }
private class myEnum<T> : IEnumerator<T>
{
public myComposite<T> _items;
int position = -1;
public myEnum(myComposite<T> list) { _items = list; }
public bool MoveNext()
{
position++;
return (position < _items.Count);
}
public void Reset() { position = -1; }
object IEnumerator.Current { get { return Current; } }
public T Current
{
get
{
try { return _items[position]; }
catch (IndexOutOfRangeException)
{ throw new InvalidOperationException(); }
}
}
public void Dispose() { }
}
}
And MainPage: - for test
public partial class MainPage : PhoneApplicationPage
{
ObservableCollection<string> listOne = new ObservableCollection<string>();
ObservableCollection<string> listTwo = new ObservableCollection<string>();
myComposite<string> composite;
public myComposite<string> Composite
{
get { return composite; }
set { composite = value; }
}
public MainPage()
{
InitializeComponent();
listOne.Add("First");
listOne.Add("Second");
listOne.Add("Third");
listTwo.Add("Fourth");
composite = new myComposite<string>(listOne, listTwo);
myList.ItemsSource = Composite;
}
}
Note that this is only a very basic example - it lacks INotifyPropertyChanged and most of methods that should be implemented. But hopefully it will show you how it works.
And of course all collections must have items of the same type.