question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DateTimePicker binding error

See original GitHub issue

Hi, I’m using MahApps.Metro 1.6.5, NET Framework 4.8, Windows 10 and Visual Studio 2019, whenever I debug my program, I’m getting:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DatePicker', AncestorLevel='1''. BindingExpression:Path=(0); DataItem=null; target element is 'DatePickerTextBox' (Name='PART_TextBox'); target property is 'Name' (type 'String')

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DatePicker', AncestorLevel='1''. BindingExpression:Path=(0); DataItem=null; target element is 'DatePickerTextBox' (Name='PART_TextBox'); target property is 'LabeledBy' (type 'UIElement')

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DatePicker', AncestorLevel='1''. BindingExpression:Path=(0); DataItem=null; target element is 'DatePickerTextBox' (Name='PART_TextBox'); target property is 'HelpText' (type 'String')

This is how my XAML looks like:

      xmlns:sys="clr-namespace:System;assembly=mscorlib"
      xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"

      <Controls:DateTimePicker x:Name="DateTimePicker" Width="170" SelectedDate="{x:Static sys:DateTime.Now}" DisplayDateEnd="{x:Static sys:DateTime.Now}" HorizontalContentAlignment="Center"/>

I tried to just create a new DateTimePicker like this: <Controls:DateTimePicker/> But still the same above error. Not sure what I’m doing wrong. I believe everything is working even with the above binding eror.

Edit: Also I tried to use DateTimePicker in another program that uses the same environment as above and I’m still getting the same above binding error.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
punker76commented, May 29, 2020

@Coke21 @Licantrop0 The BindingExpression error has now been fixed, and it will be released in the next version of MahApps.Metro

0reactions
Licantrop0commented, Feb 4, 2020

@punker76 I’m actually reproing the bug with the 2.0.0 alpha0660 and .NET Core 3.1 If I switch back to the original datepicker, I don’t see the error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failure binding value of DateTimePicker to DateTime ...
I have an object myObj with DateTime property myDate as well as a DateTimePicker control myDatePicker in my form. When I attempt to...
Read more >
Data Binding a date from a Datetimepicker - Microsoft Q&A
In VB 2019 in a form, I set up that a date is selected from a datetimepicker, and the selected date has to...
Read more >
DatePicker DateFormat data binding error
Hello Radzen Team! I'm binding the DateFormat property to a static class method, returning the correct format according to the user ...
Read more >
Binding DateTime? to EditValue of DateTimePicker not ...
I am trying to bind a DateTimePicker to a nullable DateTime ("expirydate"). Not everything has an expiry date, hence the nullable.
Read more >
System.Windows.Data Error Cannot find source for binding ...
A silent error is printed in the Output pane of Visual Studio at application startup. The error doesn't cause any issues with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found