This is a migrated thread and some comments may be shown as answers.

SelectedSlot changed trigger

10 Answers 153 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Christie Admin
Top achievements
Rank 1
Christie Admin asked on 07 May 2014, 06:13 PM
Hi,

In my ScheduleView control, I display from monday to friday, from 8:00AM to 9:00PM. In the grid, I can have appointments, specials slot and empty cells, so, I know there is an event when an appointment selection changed but I didn't find anything for "special slot" or "empty cell" selection changed!!! Can you tell me if something exist for that?

Thank's
Alain

10 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 08 May 2014, 08:41 AM
Hello Alain,

RadScheduleView does not provide such an event, but you could create a property of type Slot in your ViewModel and bind it to the SelectedSlot property of the ScheduleVIew, thus you will be notified in the ViewModel for the changes of the SelectedSlot. Please check the snippet below:

private Slot _selectedSlot;
 
public Slot SelectedSlot
{
    get
    {
        return _selectedSlot;
    }
    set
    {
        if (_selectedSlot != value)
        {
            _selectedSlot = value;
            this.OnPropertyChanged("SelectedSlot");
        }
    }
}

<telerik:RadScheduleView
...
SelectedSlot="{Binding SelectedSlot, Mode=TwoWay}">
...
</telerik:RadScheduleView>

As to the SpecialSlots - there isn't a selection for them, but when you get the selected slot, you could intersect it with the SpecialSlots collection to check whether it is amongst them.

Hope this helps.

Regards,
Yana
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Christie Admin
Top achievements
Rank 1
answered on 08 May 2014, 06:08 PM
Hi Yana,

the problem I have here is the following scenario... The MinorTickLength of my control is 60mins, I have a SpecialSlot from 8h00AM to 8h15AM and another one from 8h45AM to 9h00AM, if I click on the 8h45AM to 9h00AM spcialslot, I receive the 8h00AM to 9h00AM slot so how it's possible for me to have to proper specialslot corresponding to my mouse clicked?!?

Thank's
Alain
0
Yana
Telerik team
answered on 12 May 2014, 12:16 PM
Hi Alain,

The only solution in this case is to set the MinorTickLength to 15min as well - in this way you will be able to select the required slot without a problem.

In general, we are provided a mechanism for customizing the SlotSelectionBehavior, but it is suitable only in cases when the SelectedSlot is longer than the value set to MinorTickLength.

We're sorry for any inconvenience caused.

Regards,
Yana
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Christie Admin
Top achievements
Rank 1
answered on 16 May 2014, 03:13 PM
Hi Yana,

setting the MinorThickLengh is not a suitable solution for me :( I think I found something using the VisualTreeHelper.HitTest method but I have 2 issues with it:

1. When I click on an appointment, depending where I click inside the appointment, the HitTest found my SpotContainer and sometime not. SpotContainer if define as follow: public class SpotContainer : Grid

2. If I have a MinorThickLength of 60 mins and I have 3 SpecialSlots of 15 mins at 8h15, 8h30 and 8h45. If I click on the 8h15 SpecialSlot, the HitTest found the 8h45 SpecialSlot.

Here is my code:
this.ScheduleView.AddHandler(RadScheduleView.MouseLeftButtonDownEvent, new MouseButtonEventHandler(ScheduleView_MouseLeftButtonDown), true);

        private void ScheduleView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            VisualTreeHelper.HitTest(this.ScheduleView, null, new HitTestResultCallback(MyHitTestResult), new PointHitTestParameters(Mouse.GetPosition(this.ScheduleView)));

            // We don't want to keep the whole slot (between 2 minor tick length) selected.
            this.ScheduleView.SelectedSlot = null;
        }
        
        HitTestResultBehavior MyHitTestResult(HitTestResult result)
        {
            var current = result.VisualHit;

            while (true)
            {
                current = VisualTreeHelper.GetParent(current);

                if (current == null)
                {
                    break;
                }

                if (current.GetType() == typeof(SpotContainer))
                {
                    SpotContainer x = (SpotContainer)current;

                    if (x != null)
                    {
                        bool canBeSelected = true;

                        if (x.UnderlyingSlot != null)
                        {
                            canBeSelected = !x.IsReadOnly;
                        }

                        if (canBeSelected)
                        {
                            this.SelectedSlotOrAppointment = (SpotContainer)current;                            
                        }
                    }

                    return HitTestResultBehavior.Stop;
                }
            }

            return HitTestResultBehavior.Continue;
        }

Thank's
Alain
0
Christie Admin
Top achievements
Rank 1
answered on 17 May 2014, 03:56 AM
Hi Yana,

one thing about my previous post... In my application, I have a Slider with a range from 0 to 255, the slider value change, call a public method (SetZoomFactor) in my usercontrol which contain my scheduleview. What the method do is simply take the slider value, multiply it by 100 and assign the result to the MinTimeRulerExtent property of the viewdefinition in my scheduleview.

The default value of the property MinTimeRulerExtent assign in the XAML is 1000, so the first time I launch my application, whatever the SpecialSlot or Appointment I clicked on, the HitTest do his job and I can change the border color and border with of the SpotContainer I clicked on. If I start playing with the slider, I see the height of each cell growing but the HitTest start working bad, I mean the HitTest return or not the SpotContainer I clicked on dpending where I clicked in the cell. At this point, if I take the MinTimeRulerExtent value and I replace the calculation of the zoom in my SetZoomFactor procedure, when I restart my application, of course the zoom doesn't work, but every click I do on any cell work good.

Thank's
Alain
0
Kalin
Telerik team
answered on 21 May 2014, 02:31 PM
Hello Alain,

I'm afraid that we cannot suggest you any other solution for the desired scenario. With the current implementation of the ScheduleView the easiest way would be to change the MinorTickLength as we have already suggested.

If you have any other questions or concerns, do not hesitate to contact us.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Christie Admin
Top achievements
Rank 1
answered on 21 May 2014, 02:48 PM
Hi Kalin,

with the explanantions I gave to you regarding the HitTest in a previous post and the strange behavior of the MinTimeRulerExtent, you confirm that is an issue with the ScheduleView control?!?

Otherwise, what is the difference between having a constant value on the property which is work vs changing the value dynamically which is not work?!?

Thank's
Alain
0
Yana
Telerik team
answered on 26 May 2014, 02:05 PM
Hi Аlain,

I have reviewed again the provided information and actually what you are trying to do is to workaround the default behavior of RadScheduleView in order to achieve an unsupported scenario - selection of special slots.

As the explained scenario is more of application logic I would suggest that you take a look at our Parther Network where consulting service is provided.

Regarding the MinTimeRulerExtent property - I am not sure how the SpotContainer is implemented and whether it is expanded together with the slot, so in order to research further this issue, please open a support ticket and send us a demo project there.

Regards,
Yana
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Christie Admin
Top achievements
Rank 1
answered on 10 Jul 2014, 12:40 PM
Hi Yana,

for my personal understanding can you explain... I have a scheduleview with a weekviewdefinition fro 8AM to 9PM. The control display from 8AM to 10AM with of course a vertical scrollbar. I have my specials slots source collection with data in it. Each object in my collection is a grid named SpotContainer. Each SpotContainer contain a guid property provided by the application who filled my collection.

When I'm using the dotnet method "VisualTreeHelper.HitTest" in the MouseMove event of the ScheduleViewControl, sometime the HitTest method return null or sometime, as an example, if my mouse are over the 9AM, the HitTest method can return the SpotContainer of 8PM (My hittest method is somewhere in on of my reply).

I'm just trying to understand why the dot net VisualTreeHelper.HitTest method are not returning the good object...

Thank's
Alain 
0
Yana
Telerik team
answered on 14 Jul 2014, 08:31 AM
Hello Alain,

I have tried the explained scenario with zooming and HitTest method and it returned the correct result at our side. For the SpotContainer I used a simple implementation by just inheriting from Button. I have attached my test project for your reference. 

As your real scenario seems more complicated, I am afraid we cannot tell what could cause the .Net VisualTreeHelper.HitTest method not to return the correct values.

Regards,
Yana
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
ScheduleView
Asked by
Christie Admin
Top achievements
Rank 1
Answers by
Yana
Telerik team
Christie Admin
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or