Comments (4)
Another situation:
On Android devices, when adding an item to ObservableCollection of the base KanbanModel, it raises System.NullReferenceException: 'Object reference not set to an instance of an object.'
However, if the ObservableCollection does not bind to ItemsSource of Kanban, the exception won't occur.
I guess if it's something within the KanbanModel (e.g., the ImageURL has to be a valid filename, even if I don't need the image in the original template) that might cause this problem? Same code works on UWP.
BTW, the data initialization of Kanban is done in the overwrited OnAppearing in code-behind. Appreciate your kind help. Thanks a lot.
from xamarin-demos.
We have checked the reported issue in our SampleBrowser sample with some changes (as you mentioned - added Items inside the OnAppearing method). On that we were able to reproduce the crash issue since BindingContext of Sample is not set. The BindingContext of Sample has been set after the InitializeComponent() of Page. So, before that OnAppearing method invoked and getting null exception on provided model. It has been resolved by setting bindingContext before InitializeComponent as per in below code snippet
public partial class KanbanCustomizationSample : SampleView
{
KanbanCustomViewModel model;
public override void OnAppearing()
{
base.OnAppearing();
kanban.BindingContext = model;
model.Cards = new System.Collections.ObjectModel.ObservableCollection<CustomKanbanModel>();
model.Cards.Add(
new CustomKanbanModel()
{
ID = 1,
Title = "Margherita",
ImageURL = "margherita.png",
Category = "Menu",
Rating = 4,
Description = "The classic. Fresh tomatoes, garlic, olive oil, and basil. For pizza purists and minimalists only.",
Tags = new string[] { "Cheese" }
}
);
model.Cards.Add(
new CustomKanbanModel()
{
ID = 2,
Title = "Double Cheese",
ImageURL = "doublecheesemargherita.png",
Category = "Menu",
Rating = 5,
Description = "The minimalist classic with a double helping of cheese",
Tags = new string[] { "Cheese" }
}
);
.....
model.Cards.Add(
new CustomKanbanModel()
{
ID = 2,
Title = "Double Cheese",
ImageURL = "doublecheesemargherita.png",
Category = "Delivery",
OrderID = "Order ID - #16365",
AnimationDuration = 60000,
Description = "The minimalist classic with a double helping of cheese",
Tags = new string[] { "Cheese" }
}
);
}
And don't forget to add the NotifyPropertyChanged for Model's Data to have a notified on ItemsSource property.
public class KanbanCustomViewModel : INotifyPropertyChanged
{
private ObservableCollection<CustomKanbanModel> cards;
public ObservableCollection<CustomKanbanModel> Cards
{
get
{
return cards;
}
set
{
if (cards != value)
{
cards = value;
RaisePropertyChanged(nameof(Cards));
}
}
}
private void RaisePropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
Please check and let us know if you have any concern.
from xamarin-demos.
Sorry for belated reply. Actually I didn't adopt MVVM pattern in the project, so all the logic is in code-behind of the ContentPage. In this situation, the mentioned Exception occurs. I tried to set BindingContext in corresponding Xaml, but it didn't help.
I'm wondering if Kanban can function normally if no separate view model class is written. BTW, I used Fody.PropertyChanged to inject RaisePropertyChanged during compilation, so I didn't add the NotifyPropertyChanged explicitly. Many thanks.
from xamarin-demos.
Based on the official demo and above code, the exception still got raised when adding custom kanban model to the observable collection, even when the BindingContext was set. Thanks a lot.
System.MethodAccessException:
'Attempt by method 'BlankDemo.CustomKanbanModel.set_Rating(Single)' to access method 'Syncfusion.SfKanban.XForms.KanbanModel.RaisePropertyChanged(System.String)' failed.'
from xamarin-demos.
Related Issues (20)
- Update from Xamrin 3.6 to Latest Release Xamarin.Forms 4.8.0.1269 HOT 3
- SfAccordion HOT 2
- [Bug] SfChipGroup, SfStepProgressBar, SfAvatarView, SfRichTextEditor causes InvalidURI exception with Xamarin.Forms 5.0.0 on UWP HOT 2
- [Bug] SfSchedule raises UnhandledExceptionEventArgs Exception when double tapping the appointment if SyncfusionThemeDictionary is specified on UWP HOT 3
- Xamarin syncfusion sflistview TapGestureRecognizer not firing on Android only HOT 1
- [Bug] Doc to PDF conversion Character Overlap on Android (Font Substitution not working) HOT 3
- SfExpander raise Exception and not Rendered normally HOT 3
- [Bug] Button's click event in the DropDownFooter of SfComboBox not get called on UWP HOT 1
- SfComboBox in User Control Property value not passed HOT 8
- Many demos dont compile with current version of VS Android HOT 1
- Samples dont run on AMD virtual Debugging
- [Bug] Latest SfRotator raises ArgumentOutOfRangeException on UWP HOT 14
- PDF generation and save does not work
- SFDataGrid Editing Field Keyboard Disappear in Android 11 HOT 4
- SfBusyIndicator v20.1.0.50+ causes MemoryAccessViolation Exception on UWP HOT 1
- SampleBrowser.SfPdfViewer does not start in UWP HOT 2
- Chinese characters are not displayed HOT 1
- Blink when dragging
- Android UI kit doesnt run on Visual Studio for Mac HOT 1
- SfPdfViewer cannot open HyperLinks when targeting Android SDK 33 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xamarin-demos.