Hello dear community.
We have a problem, which results in references not being cleaned up properly and the memory leaking over time.
The application works like this:
We have a RadTabbedWindow, with RadTabItems. Those RadTabItems have Views with ViewModels (MVVM), injected via PRISM.
Now when we close the tab, the view is not unloaded or garbage collected. When analysed with Resharper DotMemory, you can see that in this example the StyleSelectors or the ResourceDictionarys keep it referenced and thus not allowing it to be collected.
To find a Solution to the problem, we have broken down the control to the most simple elements (Simplified ScheduleView.txt). When tested, we noticed that Events and StyleSelectors are keeping the items referenced. So we wrote an UnloadBehavior (which is executed when closing the tab). There is a lot more code in it, handling other stuff, but in the uploaded file (UnloadBehavior.txt) I have only left the stuff regarding this particular case.
You can see in MasterViewTop1.png (1 being the top, 2 the middle, 3 the bottom) the reference path.
In this particular code, the two StyleSelectors:
GroupHeaderStyleSelector
AppointmentStyleSelector
hinder the cleaning up.
When I give the RadScheduleView a x:Name Property and use them in code behind to set those StyleSelectors to null, it gets unloaded. Example: ObjectName.GroupHeaderStyleSelector = null;
But our application is gonna be big and we need a general solution. We don't want to give each object a name and unload StyleSelectors, Events, etc.. in the code-behind and set them to null. We need a general solution.
I can assure that neither the ViewModel, nor the code-behind is at fault. At this particular case, it's just those two StyleSelectors. I know about events, because the RadTimeBar causes the same problem, but with the VisiblePeriodChanged property, which is an event. But we want to solve this step first, which will probably solve all other problems, too. We just need to understand what has gone wrong.
Does anybody have an idea what can be done or what is wrong with the code?
I can guarantee that the UnloadBehavior is executed and reaches the DependencyProperties of the RadScheduleView and also sets them to null. But for some reason the objects and the view stay in the memory, even though they don't when I manually do it in the code-behind.
To summarise:
- We need a general solution to unload Telerik objects and clear up references for Events, StyleSelectors and everything referencing and locking the UserControl to be garbage collected.
- When done in Code-Behind it works, but when done in the UnloadBehavior nothing happens.
Hi,
I have a ScheduleView where I want it to initially be readonly. But then open for edit by clicking a toggle button.
Right now I have added the ReadOnlyBehaviour... and I can see how I can remove it.. but adding it back when clicking out of Edit mode is not so clear.
I had an idea to add a bindable property to my readonlybehaviour like this:
public class ScheduleViewReadOnlyBehaviour : ReadOnlyBehavior
{
private bool _isReadOnly;
public static readonly DependencyProperty ReadOnlyProperty =
DependencyProperty.Register(nameof(ReadOnly), typeof(bool), typeof(RadScheduleView),
new PropertyMetadata(true, ReadOnlyPropertyChanged));
private static void ReadOnlyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((ScheduleViewReadOnlyBehaviour)((RadScheduleView)d).ReadOnlyBehavior).ReadOnlyPropertyChanged((bool)e.NewValue);
}
private void ReadOnlyPropertyChanged(bool isReadOnly)
{
_isReadOnly = isReadOnly;
}
public bool ReadOnly
{
get { return (bool)GetValue(ReadOnlyProperty); }
set { SetValue(ReadOnlyProperty, value); }
}
public override bool CanSaveAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return false;
}
public override bool CanEditAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return false;
}
public override bool CanDragAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return false;
}
public override bool CanResizeAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return false;
}
public override bool CanDeleteAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return false;
}
public override bool CanEditSlot(IReadOnlySettings readOnlySettings, Slot slot)
{
return false;
}
}
But keep ending up with the GetValue and SetValue methods not found.. obviously missing a point here. Would be a nice clean way of solving this problem.
And yes, I am aware that I am currently not actually using the value being bound... I see that as the least of my issues.I have added a ScheduleView to my project and everything has been working fine as it has been readonly. Now I want to add an edit feature, where I want to allow the user to move the appointments, but the durations needs to be locked.
CustomDragDropBehaviour? or are there a simpler way of doing this?
I also need to apply some validation to the end f the move, and potentially highlight appointments that violate some rules. This I expect to be able to do with some standard validation methodology. Just need to trigger it when move of an appointment has completed.
Hi,
How can I detect if an appoint is moved?
Which event is being fired and how can I implement this in the ViewModel and View?
Thanks...
Hi,
I would like to retrieve the VisibleRangeStart and VisibleRangeEnd properties after a VisibleRangeChanged event occurs.
How can I do that in mvvm?
I can track the changed event with:
<telerik:EventToCommandBehavior.EventBindings>
<telerik:EventBinding Command="{Binding CustomCommand}" EventName="VisibleRangeChanged" />
</telerik:EventToCommandBehavior.EventBindings>
Thanks in advance,
Egbert
The Telerik WPF ScheduleView's appointment cells have a problem with intersecting times when assigning schedules within a one-minute timeframe. For example, when I drag and drop to assign a schedule like 12:30 PM - 1:30 PM, and then another schedule from 1:30 PM - 2:30 PM, sometimes it displays two cells in one column (as shown in the right corner), while other times it functions correctly (as shown in the left corner).
I must emphasize that this is a bug in the user interface. Is there a way you can address and fix this issue? Thank you!
The Telerik WPF ScheduleView's appointment cell has a problem with intersecting times when assigning schedules within a one-minute time frame. When I drag and drop to assign a schedule, such as from 12:30pm to 1:30pm, and then another schedule from 1:30pm to 2:30pm, sometimes it displays two cells in one column (as shown in the right corner), while other times it works fine (as shown in the left corner).
I must emphasize that this is a bug in the user interface. Is there a way you can fix this issue? Thank you!