ToolWindow - Custom RadDockingCommands

4 posts, 0 answers
  1. Fabien
    Fabien avatar
    2 posts
    Member since:
    Sep 2014

    Posted 09 Sep 2014 Link to this post

    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.
  2. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 10 Sep 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Fabien
    Fabien avatar
    2 posts
    Member since:
    Sep 2014

    Posted 10 Sep 2014 in reply to Kalin Link to this post

    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
  5. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 15 Sep 2014 Link to this post

    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.
     
Back to Top