Remove Label Column

9 posts, 1 answers
  1. Colin Wright
    Colin Wright avatar
    26 posts
    Member since:
    Mar 2008

    Posted 13 Jan 2012 Link to this post

    Is it possible to remove the label column within an Autogenerating DataForm?
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Jan 2012 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Colin Wright
    Colin Wright avatar
    26 posts
    Member since:
    Mar 2008

    Posted 13 Jan 2012 Link to this post

    Thanks for the reply, could you possibly give me an example of a predefined template?
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Jan 2012 Link to this post

    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 >>

  6. Colin Wright
    Colin Wright avatar
    26 posts
    Member since:
    Mar 2008

    Posted 13 Jan 2012 Link to this post

    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'.
  7. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Jan 2012 Link to this post

    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 >>

  8. Colin Wright
    Colin Wright avatar
    26 posts
    Member since:
    Mar 2008

    Posted 13 Jan 2012 Link to this post

    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
  9. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Jan 2012 Link to this post

    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 >>

  10. Colin Wright
    Colin Wright avatar
    26 posts
    Member since:
    Mar 2008

    Posted 13 Jan 2012 Link to this post

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