Telerik Forums
UI for WPF Forum
0 answers
28 views

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.

Anastasios
Top achievements
Rank 1
 asked on 12 Mar 2025
2 answers
42 views

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.       
hhgm
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 30 Jan 2025
1 answer
33 views

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.

Stenly
Telerik team
 answered on 06 Jan 2025
1 answer
49 views
We are using a RadScheduleView with a TimelineViewDefinition. We allow the user to manually change the VisibleDays of the view as well as the Selected date with a datepicker. Is it possible to remove or hide the weekends and other non-working days in the TimelineView?
Stenly
Telerik team
 answered on 22 Nov 2024
1 answer
39 views
When dragging over a timeslot in RadScheduleView. The Drag over visual showing the start and end times are always shown in 12h Format. Even though my PC locale is set to 24h format.


When dragging over the 15:00 slot, It shows 3PM and 5PM instead of 15:00 and 17:00. The timeruler correctly shows the same format as my PC locale but the drag over visual seems to always be 12h.

Stenly
Telerik team
 answered on 02 Oct 2024
1 answer
49 views

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...

Martin Ivanov
Telerik team
 answered on 13 Sep 2024
1 answer
50 views

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

Stenly
Telerik team
 answered on 04 Sep 2024
0 answers
32 views

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!

Bryan
Top achievements
Rank 1
 asked on 06 May 2024
0 answers
55 views

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!

Bryan
Top achievements
Rank 1
 asked on 04 May 2024
1 answer
56 views
How to restrict the start and end times of an appointment to be at least 10 minutes apart as an integer multiple (e.g., 10, 20, 30, etc.)?
Stenly
Telerik team
 answered on 01 May 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?