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

How to stretch content within DataForm

8 Answers 252 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Vasile
Top achievements
Rank 1
Vasile asked on 22 Mar 2011, 08:20 PM
Hello,

Just installed the last version (Q1, 2011) of Telerik Silverlight controls, and tried Telerik DataForm control by replacing the standard DataForm control in one of my the projects.

I observed two wrong behaviors so far:

1. I found no way, at least not obvious way, of stretching vertically the content within the DataForm. In my application I host the DataForm into a resizable RadPanel, inside the DataForm I have a multiline text field which is anchored on all edges, so it is supposed to resize when the DataForm resizes to benefit by the whole surface of the DataForm (this worked with standad DataForm control).
I set on RadDataForm the VerticalAlign and VerticalContentAlight to Stretch
I set also the VerticalAlign="Stretch" for the control inside the DataForm

Please let me know if there is a way to achive desired behavior.

2 A second observation I have is that if I do not specify a Foreground color for the RadDataForm the labels inside various templates would be displayed with White foreground over White background.  I don't use any special theme... just plain controls with their default style.

This can be reproduced with very simple code in brand new project

Vasile

8 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 23 Mar 2011, 04:36 PM
Hi Vasile,

 
Thank you for your interest in our bran new RadDataForm control. Please find my answers in the following order:

1.The template of our RadDataForm is a little bit different that the one that the native DataForm uses. By desing the presenters used to display fields in RadDataForm are wrapped in a ScrollViewer/StackPanel. As a result its children are measured with infinity. You may override it by editing the template of RadDataForm and just remove the ScrollViewer/StackPanel. Please refer to the attached project. 

2. We have had a similar issue, which was already fixed and is part of our latest internal build.


Greetings,
Vanya Pavlova
the Telerik team
0
Leos
Top achievements
Rank 1
answered on 03 Apr 2011, 08:36 AM
I have similar problem.
Code from XAML is here, VerticalAlignment is set to TOP and VerticalContentAlignment is set to STRECH:
<DataTemplate x:Key="detail">
  <StackPanel Orientation="Vertical">
    <telerik:DataFormDataField Label="Zalozeno:"
          DataMemberBinding="{Binding Zalozeno, Mode=TwoWay}"
          Description="Datum vlozeni zaznamu do evidence"/>
     <telerik:DataFormDataField Label="Popis:"
          Height="100"                                              
          Background="AntiqueWhite"
          VerticalAlignment="Top"
          VerticalContentAlignment="Stretch"
          DataMemberBinding="{Binding Popis, Mode=TwoWay}"
          Description="Textova informace, popis zbozi"/>
    <telerik:DataFormCheckBoxField Label="Platne:"
         DataMemberBinding="{Binding IndPlt, Mode=TwoWay}"
         Description="Priznak platnosti zaznamu"/>
  </StackPanel>
</DataTemplate>

See attached image.
Field "Popis" (Note, Comment) is not stretched. I looks as if Label is vertically centered a content is computed from Label vertical position.

Thank you very much.
Leos
0
Leos
Top achievements
Rank 1
answered on 03 Apr 2011, 09:47 AM
It works, if content (standard TextBox) is inserted into DataFormDataField.Content.
Leos

<telerik:DataFormDataField Label="Popis:"
    VerticalAlignment="Top"
    VerticalContentAlignment="Stretch"
    DataMemberBinding="{Binding Popis, Mode=TwoWay}"                                               
    Description="Textova informace, popis zbozi">
    <telerik:DataFormDataField.Content>                           
         <TextBox Text="{Binding Popis, Mode=TwoWay}"
             Height="150"
             IsReadOnly="True"
            VerticalScrollBarVisibility="Auto"
            HorizontalScrollBarVisibility="Auto"
            AcceptsReturn="True"  />                           
   </telerik:DataFormDataField.Content>
</telerik:DataFormDataField>

0
Vanya Pavlova
Telerik team
answered on 04 Apr 2011, 03:23 PM
Hi Vasile,

 


We are glad to here that you were able to find a solution by your side. You may always edit the template of any RadDataForm's part and change it in appropriate manner. I believe that it would be helpful for you to review the "Styles And Templates" online help documentation for this control.


I you have any additional information please let us know.


Kind regards,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mike
Top achievements
Rank 1
answered on 15 Oct 2012, 07:11 PM
Vanya says:

"
1.The template of our RadDataForm is a little bit different that the one that the native DataForm uses. By desing the presenters used to display fields in RadDataForm are wrapped in a ScrollViewer/StackPanel. As a result its children are measured with infinity. You may override it by editing the template of RadDataForm and just remove the ScrollViewer/StackPanel. Please refer to the attached project. 
"

The project attached to the referenced post above does not appear to provide a solution to the problem.  Can you go into more detail as to how you can accomplish removing the ScrollViewer/StackPanel?  And/or getting the RadDataForm content to stretch and fill vertically?

Thank you.
0
Mike
Top achievements
Rank 1
answered on 15 Oct 2012, 07:36 PM
I believe I have discovered my mistake.  I was not correctly setting the control template.
0
Murali
Top achievements
Rank 1
answered on 14 Feb 2015, 06:25 PM
Leos, thanks for posting the solution.  This helped me today, and probably saved good deal of time, I would not have intuitively figured this out anytime soon if I did not see this post.  Nearly two years in to the future, and this still helped.
0
Murali
Top achievements
Rank 1
answered on 15 Feb 2015, 12:54 AM

Meh, I spoke too soon.  Apparently, I didn't test enough with resizable dataform with grid splitter - be aware, it gets tricky to manage the aesthetics of the view.  I found a work around that makes this work sufficiently for my scenario, but with a constraint that you must set minwidth.  All the complication boiled down to the way this control is setup - StackPanel in scrollviewer is quite a rowdy in layouts.  Solution I ended up with is:

1. Use Grid as root element for the data template, set MaxWidth={Binding RelativeSource={RelativeSource AncestorType=Border}, Path=ActualWidth}" MinWidth="330"  [use desired MinWidth to suite your UI]
2. Use Leos's solution of setting Content of the DataFormDataField.

<Grid MaxWidth="{Binding RelativeSource={RelativeSource AncestorType=Border}, Path=ActualWidth}" MinWidth="330">
    <telerik:DataFormDataField Label="Description" LabelPosition="Above" IsEnabled="{Binding IsEditing}">
        <telerik:DataFormDataField.Content>
            <TextBox Margin="0 8 0 0" MinHeight="40" Text="{Binding Description}" TextWrapping="Wrap" AcceptsReturn="True"  VerticalAlignment="Stretch" IsEnabled="{Binding IsEditing}" />
        </telerik:DataFormDataField.Content>
    </telerik:DataFormDataField>
</Grid>


 




Tags
DataForm
Asked by
Vasile
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Leos
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Murali
Top achievements
Rank 1
Share this question
or