Ich schaffe beobachtbaren Sammlung in der KlasseWarum ändern sich Daten in bindendem XAML nicht?
public ObservableCollection<NewsTags> NewsTagsList { get; private set; }
public RelayCommand RefreshNewsTags
{
get
{
return _refreshNewsTagsCommand ?? (
_refreshNewsTagsCommand = new RelayCommand(
async() => {
var list = await _newsTagsService.GetAllAsync(1, false);
foreach (var item in list)
{
NewsTagsList.Add(item);
}
}
));
}
}
und Anrufsteuerung individuelle
<tagsListSelector:BoxSelector Items="{Binding NewsTagsList}" />
Und boxselector.cs
public partial class BoxSelector : ContentView
{
public BoxSelector()
{
InitializeComponent();
}
public static readonly BindableProperty ItemsProperty =
BindableProperty.Create<BoxSelector, IEnumerable>(
view => view.ItemsSource,
null,
propertyChanged: (bindableObject, oldValue, newValue) => {
((BoxSelector)bindableObject).ItemsSourceChanged(bindableObject, oldValue, newValue);
}
);
private void ItemsSourceChanged(BindableObject bindableObject, IEnumerable oldvalue, IEnumerable newvalue)
{
boxSelectorGrid.Children.Clear();
foreach (object obj in newvalue)
{
boxSelectorGrid.Children.Add(new Label { Text="LOL", TextColor= Color.FromHex("#000")});
}
}
aber keine Änderungen. ps.s in newslist.cs NewsTagsList.Count == 10 aber in BoxSelector == 0
was mache ich falsch?
kann ein Beispiel sein, bitte – bleggleb