Hello Zlatko,
We are not aware of any issues with binding the Xamarin RadListView to an ObservableCollection.
Please open a Support Ticket here and share your code so that I can investigate further, (you can use the attached demo and update the code so that it replicates the problem).
Demo
Here's a full demo that illustrates RadListView respects the ObservableCollection CollectionChanged event:
Runtime Result
XAML
Code-Behind, Model and ViewModel
using
System.Collections.ObjectModel;
using
Xamarin.Forms;
namespace
ObservableCollectionTest.Portable
{
public
partial
class
MainPage : ContentPage
{
public
MainPage()
{
InitializeComponent();
}
}
public
class
Book
{
public
string
Title {
get
;
set
; }
public
string
Author {
get
;
set
; }
}
public
class
ViewModel
{
public
ViewModel()
{
Books =
new
ObservableCollection<Book>{
new
Book{ Title =
"The Fault in Our Stars "
, Author =
"John Green"
},
new
Book{ Title =
"Divergent"
, Author =
"Veronica Roth"
},
new
Book{ Title =
"Gone Girl"
, Author =
"Gillian Flynn"
},
new
Book{ Title =
"Clockwork Angel"
, Author =
"Cassandra Clare"
},
new
Book{ Title =
"The Martian"
, Author =
"Andy Weir"
},
new
Book{ Title =
"Ready Player One"
, Author =
"Ernest Cline"
},
new
Book{ Title =
"The Lost Hero"
, Author =
"Rick Riordan"
},
new
Book{ Title =
"All the Light We Cannot See"
, Author =
"Anthony Doerr"
},
new
Book{ Title =
"Cinder"
, Author =
"Marissa Meyer"
},
new
Book{ Title =
"Me Before You"
, Author =
"Jojo Moyes"
},
new
Book{ Title =
"The Night Circus"
, Author =
"Erin Morgenstern"
},
};
AddBookCommand =
new
Command(ExecuteAddBookCommand);
}
private
void
ExecuteAddBookCommand(
object
obj)
{
Device.BeginInvokeOnMainThread(() =>
{
Books.Add(
new
Book
{
Title = $
"Book {Books.Count + 1}"
,
Author =
"FooBar Author"
});
});
}
public
ObservableCollection<Book> Books {
get
;
set
; }
public
Command AddBookCommand {
get
;
set
; }
}
}
Run the attached demo and click the button to add items to the collection. You'll see the RadListView also gets updated
General Troubleshooting
A few reasons why you wouldn't see the RadListView items get updated:
Consideration: On iOS you need to make sure that the linker doesn't remove the control during compilation.
Solution:
Use XamlC (recommended) or give the control an x:Name
Consideration: On Android you need to make sure you give the control vertical space to expand into (
this is the most likely reason in your case)
Solution: Making sure the RadListView is not under
any StackLayout or Grid RowDefinition where Height=Auto.
See this troubleshooting section.
Consideration: Adding items must be done on the UI thread
Solution: Make sure the logic that adds the item is being executed on the UI thread (use Device.BeginInvoke).
Consideration: Not all the dependencies have been added
Solution: Make sure you have added the
RadListView Required Telerik References (to all the projects) and the
Required Xamarin.Android Support Libraries
There are other things that might be wrong as well, but I can only determine what's wrong in your application by seeing your code directly. I will see your support ticket come in and will start working on it.
Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items