DataFormDataField Label + Control widths

6 posts, 0 answers
  1. Dan
    Dan avatar
    6 posts
    Member since:
    Sep 2013

    Posted 07 Oct 2013 Link to this post

    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.
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 08 Oct 2013 Link to this post

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

    Posted 08 Oct 2013 Link to this post

    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>


  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 09 Oct 2013 Link to this post

    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 >>
  6. Dan
    Dan avatar
    6 posts
    Member since:
    Sep 2013

    Posted 09 Oct 2013 Link to this post

    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.
  7. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 11 Oct 2013 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready