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

ToolWindow - Custom RadDockingCommands

3 Answers 105 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Fabien
Top achievements
Rank 1
Fabien asked on 09 Sep 2014, 08:26 AM
Hi,

I added a new command into PaneHeader & RadPane. It works perfectly. I try to add this command into the toolwindow control template. Here the code:

<ControlTemplate x:Key="ToolWindowControlTemplate" TargetType="telerik:ToolWindow">
       <Border x:Name="VisualRoot" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" >
           <Grid>
               <Grid.RowDefinitions>
                   <RowDefinition Height="Auto" MinHeight="22" />
                   <RowDefinition Height="*" />
               </Grid.RowDefinitions>
               <Grid.ColumnDefinitions>
                   <ColumnDefinition Width="*" />
                   <ColumnDefinition Width="Auto" />
               </Grid.ColumnDefinitions>
             
 
               <!-- Here, the new command on TOOLWINDOW-->
               <StackPanel Grid.Column="1" Orientation="Horizontal">
                   <telerik:RadButton x:Name="SettingsAction"                                   
                                  Command="local:RadDockingCommands.OpenSettingsCommand"
                                  BorderThickness="0"
                                  Height="20"
                                  Width="20"
                                  Background="Red"
                                  Content="Button"
                                  ToolTip="Open settings">
                   </telerik:RadButton>
                   <telerik:RadButton x:Name="CloseButton"  Command="telerik:WindowCommands.Close" Margin="0 0 4 0" Content="CLOSE THIS WINDOW" />
               </StackPanel>
               <ContentPresenter x:Name="Content" Margin="{TemplateBinding Padding}" Grid.Row="1" Grid.ColumnSpan="2" Content="{TemplateBinding Content}" />
           </Grid>
       </Border>
   </ControlTemplate>


The button is visible but the command is disable. I try to force the OnOpenSettingsCanExecute to true without success. I test also the PaneHeaderMenuOpen command and this command is enable.

Do you have a solution?

Thanks for reply.

3 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 10 Sep 2014, 12:00 PM
Hi Fabien,

I tested the provided code snippet and the button was working as expected. I'm attaching my sample project here so you can check it out. The observed behavior is most likely cause by the CanExecute logic of the custom command.

Hope this helps.

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
Fabien
Top achievements
Rank 1
answered on 10 Sep 2014, 02:57 PM
Hi Kalin,

Thanks. I found what's the problem. I forgot to declare it into the command manager like this:

System.Windows.Input.CommandManager.RegisterClassCommandBinding(
               typeof(Telerik.Windows.Controls.Docking.ToolWindow),
                   new System.Windows.Input.CommandBinding(
                       RadDockingCommands.OpenSettingsCommand,
                       RadDockingCommands.OnOpenSettings,
                       RadDockingCommands.OnOpenSettingsCanExecute));

 I did it only for the typeof(Telerik.Windows.Controls.RadPaneGroup).

I have already a small problem to find the datacontext from the ToolWindow.
private static object GetVMAccordingToTheSender(object sender)
       {
           // Try to cast it into PaneGroupBase
           var pg = sender as Telerik.Windows.Controls.Docking.PaneGroupBase;
           if (pg != null && pg.SelectedPane != null)
               return pg.SelectedPane.DataContext;
           else
           {
               // Try to cast it into ToolWindoW Header
               var twh = sender as Telerik.Windows.Controls.Docking.ToolWindow; [...]

I'm using a MVVM pattern. Do you have a solution? Thanks again for your help.

Regards
Fabien
0
Kalin
Telerik team
answered on 15 Sep 2014, 07:52 AM
Hello Fabien,

Can you please share some more details about the exact approach, how exactly do you get the sender? Can you try to modify the provided project in order to demonstrate your scenario? What is the type of the sender in provided code snippet?

I'm looking forward to hearing from you.

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.
 
Tags
Docking
Asked by
Fabien
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Fabien
Top achievements
Rank 1
Share this question
or