This question is locked. New answers and comments are not allowed.
I am getting this error "ItemCollection must be empty before using itemsource" when assigning the itemsource property of a listbox on the Popupopening event.
The XAML looks like
<telerikPrimitives:RadPickerBox x:Name="pikCommList" Margin="6,10,201,558" Content="Change Email/Fax" PopupOpening="GetCommData_Popup" >
<ListBox x:Name="lisComm" Background="Black" Padding="20" >
<TextBlock Margin="-2,-13,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}" Text="{Binding CommName}" Name="txtCommName"/>
</ListBox>
</telerikPrimitives:RadPickerBox>
I an querying the data in the PopupOpening Event handler and assigning the itemsource like this
private void GetCommData_Popup(object sender, object CancelEventArgs)
{
var q = (from x in lDataAdapter.GetTable<ChronicleDA.PERSONCOMM>()
where x.PERSONID == ActiveContext.Person.PersonID
join c in lDataAdapter.GetTable<ChronicleDA.COMMUNICATIONS>()
on x.COMMUNICATIONID equals c.COMMUNICATIONID
join e in lDataAdapter.GetTable<ChronicleDA.EMAIL>()
on c.COMMUNICATIONID equals e.COMMUNICATIONID
select new PersonComm { PersonID = x.PERSONID, CommTypeID = c.SYSTEMTYPEID, CommID = c.COMMUNICATIONID, CommName = e.EMAILFULLADDRESS}).Take(100);
IQueryable[] Queries = new IQueryable[] { q };
lDataAdapter.BeginExecute(
Queries,
delegate(IAsyncResult ar)
{
if (ActiveContext.ActiveQuery.QueryRunning == false) return;
ActiveContext.ActiveQuery.QueryRunning = false;
try
{
lDataAdapter.EndExecute(ar);
Dispatcher.BeginInvoke(() =>
{
var tt = q.ToList<PersonComm>();
lisComm.ItemsSource = tt;
If I remove this line from the XAML the code works fine but I do not have the textbox in the listbox assigned as I want. What do I need to do to correct this?
<TextBlock Margin="-2,-13,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}" Text="{Binding CommName}"
Thanks for your help
Daniel
The XAML looks like
<telerikPrimitives:RadPickerBox x:Name="pikCommList" Margin="6,10,201,558" Content="Change Email/Fax" PopupOpening="GetCommData_Popup" >
<ListBox x:Name="lisComm" Background="Black" Padding="20" >
<TextBlock Margin="-2,-13,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}" Text="{Binding CommName}" Name="txtCommName"/>
</ListBox>
</telerikPrimitives:RadPickerBox>
I an querying the data in the PopupOpening Event handler and assigning the itemsource like this
private void GetCommData_Popup(object sender, object CancelEventArgs)
{
var q = (from x in lDataAdapter.GetTable<ChronicleDA.PERSONCOMM>()
where x.PERSONID == ActiveContext.Person.PersonID
join c in lDataAdapter.GetTable<ChronicleDA.COMMUNICATIONS>()
on x.COMMUNICATIONID equals c.COMMUNICATIONID
join e in lDataAdapter.GetTable<ChronicleDA.EMAIL>()
on c.COMMUNICATIONID equals e.COMMUNICATIONID
select new PersonComm { PersonID = x.PERSONID, CommTypeID = c.SYSTEMTYPEID, CommID = c.COMMUNICATIONID, CommName = e.EMAILFULLADDRESS}).Take(100);
IQueryable[] Queries = new IQueryable[] { q };
lDataAdapter.BeginExecute(
Queries,
delegate(IAsyncResult ar)
{
if (ActiveContext.ActiveQuery.QueryRunning == false) return;
ActiveContext.ActiveQuery.QueryRunning = false;
try
{
lDataAdapter.EndExecute(ar);
Dispatcher.BeginInvoke(() =>
{
var tt = q.ToList<PersonComm>();
lisComm.ItemsSource = tt;
If I remove this line from the XAML the code works fine but I do not have the textbox in the listbox assigned as I want. What do I need to do to correct this?
<TextBlock Margin="-2,-13,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}" Text="{Binding CommName}"
Thanks for your help
Daniel