How to customize "operations pane" in a RadSaveFileDialog?

4 posts, 0 answers
  1. Steven
    Steven avatar
    2 posts
    Member since:
    Aug 2014

    Posted 30 Dec 2018 Link to this post

    I'm trying to use a RadSaveFileDialog to allow users to export files from my application, but before the export can be performed the user needs to configure a few options. I am wondering if it is possible to customize the "operations pane" area of a RadSaveFileDialog in order to add a few checkboxes/buttons/dropdowns that the user can configure before pressing the Save button?

    My initial thought was to create a custom SaveFileDialogControlTemplate to add the controls in, but I'm having some trouble figuring out how to access the controls from code so I can add click handlers or modify labels at runtime. Is this kind of customization possible with RadSaveFileDialog?

  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    3087 posts

    Posted 31 Dec 2018 Link to this post

    Hi Steven,

    Please check out the Styles and Templates help article which explains in details how you can edit the default control template of the File Dialogs. Note that if you add new controls in the Template, you will need to access them in OnApplyTemplate method override of the dialog. To achieve this you will need to inherit some dialog class like OpenFileDialogControl / SaveFileDialogControl / OpenFolderDialogControl.

    Another option is to use the ExplorerControl API , make changes to its template, then use it in RadWindow with additional OK / Cancel buttons and add you own handlers for them. To get started with Explorer control please visit its help article or the ExplorerControl demo in WPF Demos.

    Regards,
    Petar Mladenov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Steven
    Steven avatar
    2 posts
    Member since:
    Aug 2014

    Posted 31 Dec 2018 in reply to Petar Mladenov Link to this post

    I was initially thinking the same thing, to inherit SaveFileDialogControl and override OnApplyTemplate, but:

    1) SaveFileDialogControl is marked as sealed.

    2) It's not clear to me how to get RadSaveFileDialog to use a custom SaveFileDialogControl, since the methods that create the SaveFileDialogControl and set dialog's Content are all marked internal.

    If it's not possible to do this with the current RadSaveFileDialog then I will look into using ExplorerControl directly, but I was hoping to be able to save some time by customizing the existing dialog instead of having to essentially recreate it.

  4. Petar Mladenov
    Admin
    Petar Mladenov avatar
    3087 posts

    Posted 03 Jan Link to this post

    Hi Steven,

    Yes, I missed the fact that the SaveFileDialogControl is sealed so please accept my apologies for misleading you. What you can do is to inherit the Dialog control instead:

    public class CustomSaveFileDialgoControl : RadSaveFileDialog
        {
            static CustomSaveFileDialgoControl()
            {
                DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomSaveFileDialgoControl), new FrameworkPropertyMetadata(typeof(CustomSaveFileDialgoControl)));
            }
     
            public override void OnApplyTemplate()
            {
                base.OnApplyTemplate();
     
                Rectangle rect = this.GetTemplateChild("rectangle") as Rectangle;
            }
        }

    To edit its default control template you can follow the Editing Control Templates help article.
      <ControlTemplate TargetType="fileDialogs:SaveFileDialogControl" x:Key="SaveFileDialogControlTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                   
    <RowDefinition Height="*"/>
    ....
        <Rectangle Width="200" Height="50" Fill="DeepSkyBlue" x:Name="rectangle" Grid.Row="2"/>
            </Grid>
        </ControlTemplate>

    If you use no-xaml approach you will need additional style targetting your new type and based on setting to get the base style (BasedOn={StaticResource RadSaveFileDialogStyle}.

    In the attached screenshot you can see the result from my modification. I hope this will help you proceed further.

    Regards,
    Petar Mladenov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top