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

Find difference user interaction & code behind

1 Answer 29 Views
TimeBar
This is a migrated thread and some comments may be shown as answers.
User1564
Top achievements
Rank 1
Veteran
User1564 asked on 18 Aug 2020, 06:55 AM

Hello,

I use the property Selection & Periodstart to change values in background.
Now I want to find out, what the user selected, but I cant find the difference.

I also tried to change ActualSelectionChanged it also gets triggered by user & background.

Is there any event which only triggers by user?

Regards

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 20 Aug 2020, 01:46 PM

Hello,

Although there is no explicit way to determine whether the selection came from the UI or not, you can distinguish this by introducing a property in your viewmodel to keep track of this.

I've prepared a small sample project to demonstrate the approach I have in mind. Here's the code of interest:

        private bool isSelectionProgrammatic = false;

        private void RadTimeBar_SelectionChanged(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            if (!this.isSelectionProgrammatic)
            {
                MessageBox.Show("Selected by User");
            }
        }

        private void RadButton_Click(object sender, RoutedEventArgs e)
        {
            this.isSelectionProgrammatic = true;
            this.timeBar.SelectionStart = DateTime.Now;
            this.isSelectionProgrammatic = false;
        }
You can move this logic in your viewmodel with the help of the EventToCommandBehavior class by binding the SelectionChanged and Click events to commands in your viewmodel.

Please let me know whether a similar approach would work for you. I will be awaiting your reply.

Regards,
Dilyan Traykov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
TimeBar
Asked by
User1564
Top achievements
Rank 1
Veteran
Answers by
Dilyan Traykov
Telerik team
Share this question
or