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

Content alignment in DataFormDataField

1 Answer 51 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 25 Aug 2016, 02:50 PM

I'm trying to get the label to align left, and the text box to align left, in their respective columns. Can't make it happen. Both the label and the textbox seem to move to the same column, and have a mind of their own.

Here's the set-up:

 <Grid ShowGridLines="True" x:Name="DetailsTemplateEdit_Section_Main_Controls" HorizontalAlignment="Stretch" Background="White" MaxWidth="{Binding ActualWidth, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Border}}}">

                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MinWidth="150" MaxWidth="150"/>
                            <ColumnDefinition Width="2*"/>
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <telerik:DataFormDataField Grid.Row="0" Grid.Column="0" 
                                           Label="{x:Static properties:Resources.Compliance_Label_Name}" 
                                           DataMemberBinding="{Binding Name, Mode=TwoWay}" Template="{DynamicResource CustomDataFormDataFieldControlTemplate}">
                              <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}" 
                              IsEnabled="{Binding CanBeDeleted}" x:Name="txt_name" HorizontalAlignment="Left"    
                                  Style="{StaticResource WaterMarkTextBox}" THOR:WaterMarkTextHelper.WatermarkText="{x:Static properties:Resources.Compliance_Label_Name}"
                                  MaxLength="50" ToolTip="{x:Static properties:Resources.ComplianceSetup_tooltip_name}" />
                        </telerik:DataFormDataField>

 

So, based on an example I saw the grid should have three columns, and I tried to set the label to be in column 1, and the text box in column 2, and I need both to align to the left within their columns.

Hints ?

1 Answer, 1 is accepted

Sort by
0
Barry
Top achievements
Rank 1
answered on 25 Aug 2016, 08:02 PM

Actually, I found if I decouple the label from the DataFormDataField I could put it in column=0, and then the DataFormDataField in column=1  ...and set HorizontalContentAlignment="Left" for both and I was good.

 

                        <Label Width="150" HorizontalAlignment="Left" Content="{x:Static properties:Resources.Compliance_Label_Name}" Grid.Row="0" Grid.Column="0" />
                        <telerik:DataFormDataField Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" 
                                           DataMemberBinding="{Binding Name, Mode=TwoWay}" Template="{DynamicResource CustomDataFormDataFieldControlTemplate}">
                                <TextBox Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}" 
                                  IsEnabled="{Binding CanBeDeleted}" x:Name="txt_name" 
                                  Style="{StaticResource WaterMarkTextBox}" THOR:WaterMarkTextHelper.WatermarkText="{x:Static properties:Resources.Compliance_Label_Name}"
                                  MaxLength="50" Width="250" Margin="-15,0,0,0" ToolTip="{x:Static properties:Resources.ComplianceSetup_tooltip_name}" />
                        </telerik:DataFormDataField>

Tags
DataForm
Asked by
Barry
Top achievements
Rank 1
Answers by
Barry
Top achievements
Rank 1
Share this question
or