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

Styling the text within a DataFormDataField

1 Answer 89 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 15 Sep 2016, 11:17 PM

I've got a series of DataFormDataFields, and I want the text within one of the boxes (if generated) to call a function if it's clicked once. When I attempt to style the text, I lose the textbox itself. All I want is for the DataMemberBinding to be blue and have an underline so it looks like a hyperlink almost. Here's what I'm trying:

 

<telerik:DataFormDataField  x:Name="Number"
                                                Label="Number"
                                                LabelPosition="Above"
                                                Foreground="{DynamicResource StandardForeground}"
                                                Grid.Row="1"
                                                Margin="0"
                                                IsReadOnly="True"
                                                Mode="ReadOnly"
                                                Padding="2"
                                                DataMemberBinding="{Binding DataContext.Number, Mode=OneWay, RelativeSource={RelativeSource AncestorType=UserControl}, UpdateSourceTrigger=PropertyChanged}" Template="{DynamicResource HyperlinkNumber}"/>
 
 
            <ControlTemplate x:Key="HyperlinkNumber" TargetType="{x:Type telerik:DataFormDataField}">
   <Grid x:Name="PART_DataFormDataFieldGrid" Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
   <RowDefinition/>
                </Grid.RowDefinitions>
 
                <ContentControl x:Name="PART_Label" Grid.Row="0" Grid.Column="0" Content="Number" Foreground="{DynamicResource StandardForeground}"  Margin="5,0,0,2"/>
<ContentControl x:Name="PART_FieldsContentPresenter" Grid.Row="1" Grid.Column="0" Content="{Binding DataContext.Number, Mode=OneWay, RelativeSource={RelativeSource AncestorType=UserControl}, UpdateSourceTrigger=PropertyChanged}" Margin="2" Foreground="Blue"/>
    </Grid>
            </ControlTemplate>

 

Once I hit this point, the textbox looking element disappears so I haven't even tried getting the underline or making the element clickable. Is there some additional content control that will make the box appear? Thanks.

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 20 Sep 2016, 10:06 AM
Hello Stephen,

The built-in mechanisms for customizing a DataFormDataField is either through a custom DataField, or through the DataTemplate Selector functionality of the control. It is also possible to change the ReadOnlyTemplate/EditorTemplate/NewItemTemplate of RadDataForm at runtime, however, we do not have an example demonstrating the desired customization. Moreover, I cannot confirm that it can be even implemented.

All the best,
Stefan X1
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
DataForm
Asked by
Stephen
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or