We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

InLine Elements - get the selected one

Thread ID:

Created:

Updated:

Platform:

Replies:

150243 Dec 27,2019 05:29 PM UTC Jan 2,2020 10:39 AM UTC WPF 3
loading
Tags: GanttControl
Mirko Costadoni
Asked On December 27, 2019 05:29 PM UTC

Hi Everyone,
i was checking the demo example of the gantt with inline elements.
I didn't found how to get the selected inline element; found the way to get the selected line (with the list of the inline elements) but i need to get the single inline element selected.

let me know

thanks!!

Rachel A [Syncfusion]
Replied On December 30, 2019 01:03 PM UTC

Hi Mirko, 
 
Greetings from Syncfusion. 
 
GanttControl does not have direct support to get the selected inline item. So, we have achieved your requirement by hooking PreviewMouseLeftButtonDown event for GanttChart and get the selected inline item from DataContext of its e.OriginalSource argument value. Please find the snippet from below 
 
[C#]: 
 
public MainWindow() 
{ 
    InitializeComponent(); 
    Gantt.Loaded += Gantt_Loaded; 
} 
 
private void Gantt_Loaded(object sender, RoutedEventArgs e) 
{ 
    GanttChart chart = this.Gantt.FindElementOfType<GanttChart>(); 
    chart.PreviewMouseLeftButtonDown += Chart_PreviewMouseLeftButtonDown; 
} 
 
private void Chart_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) 
{ 
    Border border = e.OriginalSource as Border; 
    if (border != null && border.DataContext is Item) 
    { 
        // You can get the selected inline item from its dataContext as like below. 
        Item selectedInLineItem = border.DataContext as Item; 
    } 
} 
 
 
Please find the sample from the below link 
 
Regards, 
Rachel. 


Mirko Costadoni
Replied On December 31, 2019 04:39 PM UTC

that's good!
i've added some lines to the Chart_PreviewMouseLeftButtonDown event cause it works only if you click on the specific border.

            Item selectedInLineItem = null;
            Border border = e.OriginalSource as Border;
            if (border != null && border.DataContext is Item)
            {
                selectedInLineItem = border.DataContext as Item;
            }
            if (selectedInLineItem == null)
            {
                Grid grid = e.OriginalSource as Grid;
                if (grid != null && grid.DataContext is Item)
                {
                    selectedInLineItem = grid.DataContext as Item;
                }
            }

Rachel A [Syncfusion]
Replied On January 2, 2020 10:39 AM UTC

Hi Mirko, 
 
We would like to inform that, in our previous update, we have provided workaround to get the inline item’s instance while click on it by using GanttChart’s PreviewMouseLeftButtonDown event.  
 
We have updated the sample which is provided in our previous update with the provided snippet and checked the reported problem by select anywhere in the inline item. We afraid we are not able to reproduce the reported problem. Can you please check with the tested sample and video in the following location? 
 
 
 
If still you are facing the problem, please revert us by modifying the sample based on your application along with replication steps like short video and configuration details, etc. This would be helpful for us to give better solution in this. 
 
We have checked with the below configuration 
 
Visual Studio Version: 2019, V16.3.3 
Windows Version: 1903 
Syncfusion Version: 17.4.0.40 
 
Note: The selection of the inline items is done by clicking on the node. 
 
Regards, 
Rachel. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon