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

Remove Label Column

8 Answers 51 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Colin Wright
Top achievements
Rank 1
Colin Wright asked on 13 Jan 2012, 10:29 AM
Is it possible to remove the label column within an Autogenerating DataForm?

8 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 13 Jan 2012, 02:40 PM
Hello,

 Yes, it is possible. You need to predefine the template of the DataFormDataField as per your requirement.
Then in the AutoGeneratingField event handler, set the predefined control template:

private void DataForm_AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
       {
           if (e.PropertyName == "ID")
           {
               e.DataField.Template = this.Resources["DataFormDataFieldTemplate"] as ControlTemplate;
           }            
       }

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Colin Wright
Top achievements
Rank 1
answered on 13 Jan 2012, 02:51 PM
Thanks for the reply, could you possibly give me an example of a predefined template?
0
Dimitrina
Telerik team
answered on 13 Jan 2012, 03:04 PM
Hello,

 You may predefine the template using Expression Blend. You need to change the original template like so:

....
<Grid x:Name="PART_DataFormDataFieldGrid" Margin="{TemplateBinding Padding}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />                   
                        <ColumnDefinition Width="24"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <!--<TextBlock x:Name="PART_Label" Margin="5,0" Text="{TemplateBinding Label}"/>-->
                    <ContentPresenter x:Name="PART_ContentPresenter" Content="{TemplateBinding Content}" Grid.Column="0" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="5,0" Grid.Row="1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    <Grid x:Name="DescriptionIcon" Grid.Column="1" Height="16" Margin="4,0" Grid.Row="1" Visibility="{Binding Description, Converter={StaticResource DescriptionVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}" Width="16">
....

In the code snippet I have commented the "PART_Label" part and I have changed the column definitions for the container's Grid.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Colin Wright
Top achievements
Rank 1
answered on 13 Jan 2012, 03:28 PM
When I try and create template in my App.xaml file I get an error with

Error 1 Cannot find the static member 'ContentProperty' on the type 'Control'.
0
Accepted
Dimitrina
Telerik team
answered on 13 Jan 2012, 03:37 PM
Hello,

 I have attached a sample project. It is for Silverlight, but you should do the same for your WPF project.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Colin Wright
Top achievements
Rank 1
answered on 13 Jan 2012, 04:03 PM
Many Thanks for the sample, I have implemented but from my attached screenshot I still have large white space on the left hand side where there appears to be the label column
0
Dimitrina
Telerik team
answered on 13 Jan 2012, 04:10 PM
Hello,

 May you please send me how exactly have you predefined the template?

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Colin Wright
Top achievements
Rank 1
answered on 13 Jan 2012, 04:20 PM
Your example worked perfectly the reason for the white space was down to width settings of the controls within the form. Many thanks for your help
Tags
DataForm
Asked by
Colin Wright
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Colin Wright
Top achievements
Rank 1
Share this question
or