Hi,
As mentioned in previous posts I'm moving our WinRT app to Xamarin forms. I'm having lots of issues with TreeMap. The scenario is we are using PRISM for XF to help out with MVVM. I've created a bindable observablecollection of TreeMapItems like this:
ObservableCollection<TreeMapItem> _MyData = default(ObservableCollection<TreeMapItem>);
public ObservableCollection<TreeMapItem> MyData { get { return _MyData; } set { SetProperty(ref _MyData, value); } }
If I initialize MyData in the viewmodel constructor like this:
MyData = new ObservableCollection<TreeMapItem>() { new TreeMapItem() { Label="test", Weight=5, ColorWeight=5 } };
I will get items showing up on the TreeMap control. So I know the Binding between the View and the ViewModel is working and that the TreeMap is visible and capable of rendering data. But that's of very limited use since we change what the TreeMap show depending on which user's data the current page is showing.
We load that user data in Prism's OnNavigatedTo event handler, though I've tested by firing another event after that page finishes loading without using PRISM. The end result is that no matter what I do the TreeMap is never updated regardless of how MyData is populated. We have seen issues with other custom controls where doing an .Add to an observablecollection doesn't update the control (or I guess in Xamarin terms the "view"). The normal workaround for that is to create a separate temporary ObservableCollection, fill it with data, and then assign the temp collection to the real one and call OnPropertyChanged("MyData"). This also doesn't work.
I've even tried creating a separate class with a BindableProperty like in the example and used that (which we shouldn't have to create our own BindableProperty objects unless we are writing an extension) and it wouldn't update once the TreeMap was rendered either.
What is the proper way to update the Items from a ViewModel when using MVVM or is there an issue with the Item's property like we found in the SfChart?
This one is critical and will prevent us from launching on other platforms, so any help is greatly appreciated.
Thank you all for the amazing support you provide.