Articles in this section
Category / Section

How can I detect the dragging operation of the splitter?

1 min read

Dragging operation of the splitter in the TabSplittter control can be detected by the DragStarted and DragCompleted events. These events are handled by the splitter that is fetched from the template of the TabSplitter.

XAML

//This code demonstrates how to add the TabSplitter and TabSplitterItem:
<Window x:Class="TabsplitterSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <syncfusion:TabSplitter Name="tabsplitter">
            <syncfusion:TabSplitterItem>
                <syncfusion:TabSplitterItem.TopPanelItems>
                    <syncfusion:SplitterPage Header="Tab1"/>
                </syncfusion:TabSplitterItem.TopPanelItems>
                <syncfusion:TabSplitterItem.BottomPanelItems>
                     <syncfusion:SplitterPage Header="Tab2"/>
                </syncfusion:TabSplitterItem.BottomPanelItems>
            </syncfusion:TabSplitterItem>
        </syncfusion:TabSplitter>
    </Grid>
</Window>

 

C#

//This code demonstrates how to access the events of DragStarted and DragCompleted for the splitter:
using Syncfusion.Windows.Tools.Controls;
namespace TabsplitterSample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            tabsplitter.Loaded += new RoutedEventHandler(tabsplitter_Loaded);
        }
        private bool TabSplitterDragging;
        void tabsplitter_Loaded(object sender, RoutedEventArgs e)
        {
// This code shows that the splitter has been taken from the Template of the TabSplitter
           CustomGridSplitter splitter = tabsplitter.Template.FindName("PART_Splitter", tabsplitter) as CustomGridSplitter;
           if (splitter != null)
           {
// This code shows the DragStarted and DragCompleted Events of the splitter
               splitter.DragStarted += new System.Windows.Controls.Primitives.DragStartedEventHandler(splitter_DragStarted);
               splitter.DragCompleted += new System.Windows.Controls.Primitives.DragCompletedEventHandler(splitter_DragCompleted);
           }
        }
        void splitter_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
        {
            TabSplitterDragging = false;
        }
        void splitter_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
        {
            TabSplitterDragging = true;
        }
    }
}

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied