RadDataForm - Customize Visual Layout

2 posts, 1 answers
  1. Kyle
    Kyle avatar
    7 posts
    Member since:
    Sep 2016

    Posted 30 Jan 2017 Link to this post

    Is it possible to change the layout of the RadDatForm control in the auto-generate layout, such that instead of just having one column of property/value pairs, you can define multiple, or at least two?

    I know that I can create any layout by providing custom NewItem/ReadOnly/Edit templates. However, in order to do that, I would need to design specific templates for each DB table I want to work with, and I have many. For now, I would like to work with the auto-generated layout, but be able to better utilize the available screen space (hence the desire for more than one column with the auto-generate layout). With the current format (one property/value pair per row), I sometimes end up with a list of items that needs to be vertically scrolled, while I have lots of horizontal screen width being wasted.

    Is this possible without creating custom templates for each edited table?

  2. Answer
    Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    665 posts

    Posted 02 Feb 2017 Link to this post

    Hi Kyle,

    It should possible to achieve the desired behavior by modifying the default Control Template of the RadDataForm.  More specifically, If you investigate the Control Template of the DataForm you will notice that it contains an AutoGeneratedFieldsPresenter which holds all the autogenerated fields.
    You can edit its Control Template and replace theItemsControl within it with a custom element:

    <Style TargetType="dataForm:AutoGeneratedFieldsPresenter">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="dataForm:AutoGeneratedFieldsPresenter">
                            <ItemsControl IsTabStop="False"
                                          ItemsSource="{TemplateBinding Fields}">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <VirtualizingStackPanel Orientation="Vertical"/>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
    </Style>

    However, you might need to apply heavy customizations to achieve a consistent behavior and usually, such operations are not recommended. We cannot guarantee for certain that such functionality can be achieved.

    A recommended approach would be to utilize the ReadOnly/Edit templates, as you have already commented.  I suggest you consider a more generic approach of applying such templates.

    Regards,
    Stefan Nenchev
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top