DateTimePicker binding error
See original GitHub issueHi, 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:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Coke21 @Licantrop0 The BindingExpression error has now been fixed, and it will be released in the next version of MahApps.Metro
@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.