Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9113411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:57:29+00:00 2026-06-17T03:57:29+00:00

I have a telerik close button on a dock that I am wanting to

  • 0

I have a telerik close button on a dock that I am wanting to override the style of to allow the user to make a choice of what they want to close.

Take Notepad++ for example.. There is a “Close” and a “Close all BUT this” option.

That is exactly what I am wanting to do with this telerik radDock close button.

I have researched this and could not find anything helpful enough to really get me started. I just started using WPF (and really C#) so any helpful advice, code, or sample projects would be appreciated. Thank you in advanced.

Metro Smurf, it is pretty much exactly like the tutorial at this point. I am pretty new to WPF and C# so please be nice haha.

Here is my XAML:

<Window x:Class="RadDockCloseButton1.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                xmlns:local="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Docking"
                Title="MainWindow" Height="350" Width="525">

<Window.Resources>
    <DataTemplate x:Key="ContextMenuTemplate">
        <telerik:RadContextMenu InheritDataContext="False">
            <telerik:RadMenuItem
                IsChecked="{Binding IsFloatingOnly}"
                Command="telerik:RadDockingCommands.Floating"
                CommandParameter="{Binding}"
                CommandTarget="{Binding}"
                Header="{Binding Command.Text, RelativeSource={RelativeSource Self}}"/>

            <telerik:RadMenuItem
                IsChecked="{Binding IsDockableOptionChecked}"
                Command="telerik:RadDockingCommands.Dockable"
                CommandParameter="{Binding}"
                CommandTarget="{Binding}"
                Header="{Binding Command.Text, RelativeSource={RelativeSource Self}}" />

            <telerik:RadMenuItem
                Command="local:RadDockingCommands.CloseAllButThisCommand"
                CommandParameter="{Binding}"
                CommandTarget="{Binding}"
                Header="{Binding Command.Text, RelativeSource={RelativeSource Self}}" />

        </telerik:RadContextMenu>
    </DataTemplate>

    <Style TargetType="telerik:RadPane">
        <Setter Property="ContextMenuTemplate" Value="{StaticResource ContextMenuTemplate}" />
    </Style>

</Window.Resources>

<Grid>
    <telerik:RadDocking x:Name="radDocking">
        <telerik:RadDocking.DocumentHost>
            <telerik:RadSplitContainer>
                <telerik:RadPaneGroup x:Name="radPaneGroup">
                    <telerik:RadPane TitleTemplate="{StaticResource ContextMenuTemplate}" Title="Pane 1">
                        <TextBlock Text="Some simple text here"/>
                    </telerik:RadPane>
                </telerik:RadPaneGroup>
            </telerik:RadSplitContainer>
        </telerik:RadDocking.DocumentHost>
    </telerik:RadDocking>

</Grid>

</Window>

Here is my C#:

using System.Windows;

namespace RadDockCloseButton1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        public static class RadDockingCommands
        {
            private static RoutedUICommand closeAllPanesButThisCommand;

            public static RoutedUICommand CloseAllPanesButThisCommand
            {
                get
                {
                    if (closeAllPanesButThisCommand == null)
                    {
                        closeAllPanesButThisCommand = new RoutedUICommand("Close all panes but this", "CloseAllPanesButThisCommand", typeof(RadDockingCommands));
                    }

                    return closeAllPanesButThisCommand;
                }
            }

            public static void OnCloseAllPanesButThis(object sender, ExecutedRoutedEventArgs e)
            {
                var pane = e.Parameter as RadPane;
                if (pane != null)
                {
                    var paneGroup = pane.PaneGroup;
                    if (paneGroup != null)
                    {
                        var panesToClose = paneGroup.EnumeratePanes().Where(x => !x.IsHidden && x.IsPinned);
                        foreach (var paneToClose in panesToClose)
                        {
                            if (paneToClose != pane)
                            {
                                paneToClose.IsHidden = true;
                            }
                        }
                    }
                }
            }

            public static void OnCloseAllPanesButThisCanExecute(object sender, CanExecuteRoutedEventArgs e)
            {
                e.CanExecute = false;
                var paneGroup = sender as RadPaneGroup;
                if (paneGroup != null)
                {
                    int childrenCount = paneGroup.EnumeratePanes().Count(x => !x.IsHidden && x.IsPinned);

                    if (childrenCount > 1)
                    {
                        e.CanExecute = true;
                    }
                    else
                    {
                        e.CanExecute = false;
                    }
                }
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:57:31+00:00Added an answer on June 17, 2026 at 3:57 am

    I’m adding a second answer with a full and complete code sample. Note that the entirety of this sample was directly taken from the Telerik How to Customize or Remove the RadPane’s Menu. I’ve only put the pieces together from the various snippets. In other words, this is an OOB implementation from the Telerik tutorial.

    XAML

    <Window x:Class="so.Tel.RadPaneCloseAll.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:so.Tel.RadPaneCloseAll"
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
            Title="MainWindow"
            Width="525"
            Height="350"
            WindowStartupLocation="CenterScreen">
        <Window.Resources>
            <DataTemplate x:Key="ContextMenuTemplate">
                <telerik:RadContextMenu InheritDataContext="False">
                    <telerik:RadMenuItem Command="telerik:RadDockingCommands.Floating"
                                         CommandParameter="{Binding}"
                                         CommandTarget="{Binding}"
                                         Header="{Binding Command.Text,
                                                          RelativeSource={RelativeSource Self}}"
                                         IsChecked="{Binding IsFloatingOnly}" />
    
                    <telerik:RadMenuItem Command="telerik:RadDockingCommands.Dockable"
                                         CommandParameter="{Binding}"
                                         CommandTarget="{Binding}"
                                         Header="{Binding Command.Text,
                                                          RelativeSource={RelativeSource Self}}"
                                         IsChecked="{Binding IsDockableOptionChecked}" />
    
                    <telerik:RadMenuItem Command="local:RadDockingCommands.CloseAllPanesButThisCommand"
                                         CommandParameter="{Binding}"
                                         CommandTarget="{Binding}"
                                         Header="{Binding Command.Text,
                                                          RelativeSource={RelativeSource Self}}" />
                </telerik:RadContextMenu>
            </DataTemplate>
    
            <Style TargetType="telerik:RadPane">
                <Setter Property="ContextMenuTemplate" Value="{StaticResource ContextMenuTemplate}" />
            </Style>
        </Window.Resources>
        <Grid>
    
            <telerik:RadDocking>
                <telerik:RadDocking.DocumentHost>
                    <telerik:RadSplitContainer>
                        <telerik:RadPaneGroup>
                            <telerik:RadPane Header="Pane 1" />
                            <telerik:RadPane Header="Pane 2" />
                            <telerik:RadPane Header="Pane 3" />
                            <telerik:RadPane Header="Pane 4" />
                            <telerik:RadPane Header="Pane 5" />
                        </telerik:RadPaneGroup>
                    </telerik:RadSplitContainer>
                </telerik:RadDocking.DocumentHost>
            </telerik:RadDocking>
    
        </Grid>
    </Window>
    

    Code Behind

    using System.Linq;
    using System.Windows;
    using System.Windows.Input;
    using Telerik.Windows.Controls;
    
    namespace so.Tel.RadPaneCloseAll
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
    
                CommandManager.RegisterClassCommandBinding(
                    typeof( RadPaneGroup ),
                    new CommandBinding(
                            RadDockingCommands.CloseAllPanesButThisCommand,
                            RadDockingCommands.OnCloseAllPanesButThis,
                            RadDockingCommands.OnCloseAllPanesButThisCanExecute ) );
            }
        }
    
        public static class RadDockingCommands
        {
            private static RoutedUICommand closeAllPanesButThisCommand;
    
            public static RoutedUICommand CloseAllPanesButThisCommand
            {
                get
                {
                    if( closeAllPanesButThisCommand == null )
                    {
                        closeAllPanesButThisCommand = new RoutedUICommand( "Close all panes but this",
                                                                           "CloseAllPanesButThisCommand",
                                                                           typeof( RadDockingCommands ) );
                    }
                    return closeAllPanesButThisCommand;
                }
            }
    
            public static void OnCloseAllPanesButThis( object sender, ExecutedRoutedEventArgs e )
            {
                var pane = e.Parameter as RadPane;
                if( pane != null )
                {
                    var paneGroup = pane.PaneGroup;
                    if( paneGroup != null )
                    {
                        var panesToClose = paneGroup.EnumeratePanes().Where( x => !x.IsHidden && x.IsPinned );
                        foreach( var paneToClose in panesToClose )
                        {
                            if( paneToClose != pane )
                            {
                                paneToClose.IsHidden = true;
                            }
                        }
                    }
                }
            }
    
            public static void OnCloseAllPanesButThisCanExecute( object sender, CanExecuteRoutedEventArgs e )
            {
                e.CanExecute = false;
                var paneGroup = sender as RadPaneGroup;
                if( paneGroup != null )
                {
                    int childrenCount = paneGroup.EnumeratePanes().Count( x => !x.IsHidden && x.IsPinned );
    
                    if( childrenCount > 1 )
                    {
                        e.CanExecute = true;
                    }
                    else
                    {
                        e.CanExecute = false;
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple page that pops up a telerik radwindow on button click.
I have a Telerik Grid which has a footer that needs to display column
I have a Telerik RadGrid with a GridTemplateColumn that contains a checkbox, as follows:
I have a Telerik MVC DatePicker in a Telerik Grid. I want to let
I have a telerik radgrid that is doing an insert using an objectdatasource. The
I have several telerik radcomboboxes inside a div with various id's. I want to
I have a telerik:RadGrid that is bound to a SQL Data Source. One of
I have a Telerik MVC Grid and I want the selected to be forced
Requirement: Allow user to enter date in the format of ###### while also have
I have a telerik listview that is generating to much html for my slide

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.