-
Notifications
You must be signed in to change notification settings - Fork 1.9k
XAML Data Binding Error - Object reference not set to an instance of an object. #25819
Copy link
Copy link
Closed
Labels
area-xamlXAML, CSS, Triggers, BehaviorsXAML, CSS, Triggers, Behaviorsfixed-in-9.0.21platform/androids/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Milestone
Description
Description
When trying to bind a label's text to a back end property that has a complex model I am getting this error:
"Object reference not set to an instance of an object."
An example of this can be found in the reproduction repo for the label:
<Label
HorizontalTextAlignment="Center"
Style="{DynamicResource TextHeadline}"
Text="{Binding UsersData.InstalmentPlans.InstalmentPlan[0].FinancialYear}" />Here is the data model:
public partial class UserDataViewModel : ObservableObject
{
public UsersDataModel UsersData { get; set; }
public UserDataViewModel()
{
UsersData = new UsersDataModel
{
InstalmentPlans = new InstalmentPlans
{
InstalmentPlan = new[]
{
new InstalmentPlan { FinancialYear = "2023" }
}
}
};
}
}We have successfully used the list index in other places to bind the XAML
Steps to Reproduce
Link to the reproduction link below
Link to public reproduction project repository
https://github.com/kycuff/TestApp.git
Version with bug
8.0.40 SR5
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 13
Did you find any workaround?
Create a new field within the code behind file to retrieve UsersData.InstalmentPlans.InstalmentPlan[0].FinancialYear and bind that to the label
Relevant log output
15:57:32:097 2> Resource: App.Routes.CouncilTax.Pages.Specific.InstalmentsPage.xaml
15:57:32:097 2> Parsing Xaml
15:57:32:097 2> done.
15:57:32:097 2> Replacing 0.InitializeComponent ()
15:57:32:097 2> failed.
15:57:32:097 2> Routes\CouncilTax\Pages\Specific\InstalmentsPage.xaml : XamlC error : Object reference not set to an instance of an object.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-xamlXAML, CSS, Triggers, BehaviorsXAML, CSS, Triggers, Behaviorsfixed-in-9.0.21platform/androids/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
Done