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

DataFormDataField Label + Control widths

5 Answers 293 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 07 Oct 2013, 10:06 PM
Is there any (easy) way to create a fixed width label with a variable width edit control (anchored at left, expands to fill available space to the right)? I am not AutoGenerating the fields, but I would prefer to use the telerik:DataFormDataField control for the sake of simplicity, rather than butcher together my own mess using a StackPanel or something similar.

I have a number of resizable forms, and the default way that labels and controls resize themselves doesn't really work that well.

Thanks,

Dan.

5 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 08 Oct 2013, 06:15 AM
Hi,

 In order to achieve this you should edit RadDataForm's ControlTemplate in Blend or VS2012. Currently fields' layout panel is a grid with 3 columns:

<Grid.ColumnDefinitions>
                   <ColumnDefinition Width="*"/>
                   <ColumnDefinition Width="2*"/>
                   <ColumnDefinition Width="24"/>
               </Grid.ColumnDefinitions>
               <Grid.RowDefinitions>
                   <RowDefinition/>
                   <RowDefinition/>
               </Grid.RowDefinitions>
The first column hosts the label, the second - the editor and the last one is used to display the description indicator, in case the respective DataAnnotations attribute is present. You can set fixed width to the first column and your requirements should be fulfilled.Regards,
Ivan Ivanov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Dan
Top achievements
Rank 1
answered on 08 Oct 2013, 06:40 PM
Thanks for your reply, but I'm still completely confused. I've created a small project in Visual Studio 2012 and when I try to open it in Blend,  I'm not seeing any of the things mentioned on this page: http://www.telerik.com/help/wpf/raddataform-styles-and-templates-templates-structure.html Blend just complains that it can't open the project properly and then pretty much just disables everything once I do open it...

I'm new to WPF and while I very much want to learn it, so far it seems about as friendly as a rabid pitbull. I'm really interested in using the OpenAccess ORM for a new project, and I figured I might as well go all the way and do the UI in WPF with controls designed to be used with it, but I seem to be spending an inordinate amount of time trying to bend the UI into something useful that can be trivially done in 2 minutes with WinForms...

All I want to do is take this UserControl and style it so that the labels are fixed width and the controls themselves are anchored at the left and will stretch right as necessary.
<UserControl
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:DataForm="clr-namespace:Telerik.Windows.Controls.Data.DataForm;assembly=Telerik.Windows.Controls.Data" x:Class="PandaUI.Controls.ArtistInfo"
             mc:Ignorable="d" Width="409" Height="237">
    <Grid>
        <Grid.Resources>
            <DataTemplate x:Key="MyTemplate">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="75*"/>
                        <ColumnDefinition Width="25*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                </Grid>
            </DataTemplate>
        </Grid.Resources>
 
        <telerik:RadDataForm x:Name="dfArtistInfo" Margin="10" AutoGenerateFields="True"
            EditTemplate="{StaticResource MyTemplate}"
            NewItemTemplate="{StaticResource MyTemplate}"
            ReadOnlyTemplate="{StaticResource MyTemplate}" />
    </Grid>
</UserControl>


0
Ivan Ivanov
Telerik team
answered on 09 Oct 2013, 06:57 AM
Hi,

 I guess that you are trying to open a WPF 4.5 project in Blend 4, which supports only .Net 4 and lower versions. However, you can use VS2012 instead. Please, open the respective view in the designer, right-click the RadDataForm and choose edit template > edit a copy from the context menu. Then you can modify the grid panel in the ControlTemplate copy. Bare in mind that you should not use * size if you want constant width. Here is an article that sheds some more light on the matter.

Regards,
Ivan Ivanov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Dan
Top achievements
Rank 1
answered on 09 Oct 2013, 07:48 PM
I am trying to change the DataFormDataField Template - the thing that contains the label and the control. But when I edit a copy of the form template, it doesn't contain a single reference to anything mentioned here: http://www.telerik.com/help/wpf/raddataform-styles-and-templates-templates-structure.html#DataFormDataField

All I want to do is make the label fixed width, anchor the control on the left side and have it expand to fill the available space to the right.
0
Ivan Ivanov
Telerik team
answered on 11 Oct 2013, 01:06 PM
Hi,

Alternatively you can find the template in the XAML files that are shipped with the RadControls installation: Telerik\RadControls...\Themes\WPF40\Windows8\Themes\Telerik.Windows.Controls.Data 

Regards,
Ivan Ivanov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
DataForm
Asked by
Dan
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Dan
Top achievements
Rank 1
Share this question
or