I'm using a RadScheduleView with some combobox dropdowns to set filter options. Here's how I set this up (excess code has been removed):
When I use this, I get a binding error after it's first initialized:
Get System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=AppointmentFilter; DataItem='CalendarViewModel' (HashCode=6511533); target element is 'MonthViewDefinition' (HashCode=63187382); target property is 'AppointmentFilter' (type 'Predicate`1')
But other than that, everything works as I expect. My appointments are displayed as per my filter settings. As I change my dropdown, the AppointmentFilter gets called for every appointment and the visible appointments are changed to match the filter.
But, if I remove setting of the DataContext from the xaml:
and move it to the code behind:
Now, instead of seeing the "governing FrameworkElement" binding error first, the AppointmentFilter is called for each appointment right away, but then I get the binding error at the end:
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=AppointmentFilter; DataItem=null; target element is 'MonthViewDefinition' (HashCode=32578312); target property is 'AppointmentFilter' (type 'Predicate`1')
At this point, ALL appointments are displayed, not just the ones that meet the filter requirements.
Even worse is that, as I change the dropdown, the AppointmentFilter gets called for every appointment as I expect, but the visible appointments don't change!! For some reason, the AppointmentFilter is called, but then completely ignored, so all appointments are displayed.
As far as I can tell, the governing FrameworkElement binding is known WPF behavior. What I don't understand is why RadScheduleView doesn't fully recover from this. Since the AppointmentFilter is being called, it seems to partially recover, but then the results of the filtering are ignored.
How can I fix this problem?
Thank you!
<
UserControl
x:Class
=
"CalendarsContainer"
<Grid
x:Name
=
"ScheduleGrid"
>
<
Grid.DataContext
>
<
viewModels:CalendarViewModel
/>
</
Grid.DataContext
>
<
telerik:RadComboBox
Grid.Row
=
"0"
SelectedValue
=
"{Binding TaskFilter, Mode=TwoWay}"
/>
<
telerik:RadScheduleView
Grid.Row
=
"1"
AppointmentsSource
=
"{Binding Appointments}"
>
<
telerik:RadScheduleView.ViewDefinitions
>
<
telerik:MonthViewDefinition
AppointmentFilter
=
"{Binding AppointmentFilter}"
/>
</
telerik:RadScheduleView.ViewDefinitions
>
</
telerik:RadScheduleView
>
</
Grid
>
</
UserControl
>
When I use this, I get a binding error after it's first initialized:
Get System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=AppointmentFilter; DataItem='CalendarViewModel' (HashCode=6511533); target element is 'MonthViewDefinition' (HashCode=63187382); target property is 'AppointmentFilter' (type 'Predicate`1')
But other than that, everything works as I expect. My appointments are displayed as per my filter settings. As I change my dropdown, the AppointmentFilter gets called for every appointment and the visible appointments are changed to match the filter.
But, if I remove setting of the DataContext from the xaml:
<
UserControl
x:Class
=
"CalendarsContainer"
<Grid
x:Name
=
"ScheduleGrid"
>
<
telerik:RadComboBox
Grid.Row
=
"0"
SelectedValue
=
"{Binding TaskFilter, Mode=TwoWay}"
/>
<
telerik:RadScheduleView
Grid.Row
=
"1"
AppointmentsSource
=
"{Binding Appointments}"
>
<
telerik:RadScheduleView.ViewDefinitions
>
<
telerik:MonthViewDefinition
AppointmentFilter
=
"{Binding AppointmentFilter}"
/>
</
telerik:RadScheduleView.ViewDefinitions
>
</
telerik:RadScheduleView
>
</
Grid
>
</
UserControl
>
and move it to the code behind:
public
CalendarsContainer()
{
InitializeComponent();
ScheduleGrid.DataContext =
new
CalendarViewModel();
}
Now, instead of seeing the "governing FrameworkElement" binding error first, the AppointmentFilter is called for each appointment right away, but then I get the binding error at the end:
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=AppointmentFilter; DataItem=null; target element is 'MonthViewDefinition' (HashCode=32578312); target property is 'AppointmentFilter' (type 'Predicate`1')
At this point, ALL appointments are displayed, not just the ones that meet the filter requirements.
Even worse is that, as I change the dropdown, the AppointmentFilter gets called for every appointment as I expect, but the visible appointments don't change!! For some reason, the AppointmentFilter is called, but then completely ignored, so all appointments are displayed.
As far as I can tell, the governing FrameworkElement binding is known WPF behavior. What I don't understand is why RadScheduleView doesn't fully recover from this. Since the AppointmentFilter is being called, it seems to partially recover, but then the results of the filtering are ignored.
How can I fix this problem?
Thank you!