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

RadDataForm - Customize Visual Layout

1 Answer 122 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 1
Kyle asked on 30 Jan 2017, 03:29 PM

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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan Nenchev
Telerik team
answered on 02 Feb 2017, 02:56 PM
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 you to write beautiful native mobile apps using a single shared C# codebase.
Tags
DataForm
Asked by
Kyle
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Share this question
or