Styling the text within a DataFormDataField

2 posts, 0 answers
  1. Stephen
    Stephen avatar
    1 posts
    Member since:
    Sep 2016

    Posted 15 Sep Link to this post

    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.

  2. Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 20 Sep Link to this post

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