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

Display Metadata as label

3 Answers 63 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Trevor
Top achievements
Rank 1
Trevor asked on 19 Sep 2011, 10:15 PM
have a domain data source that I have annotated with some metadata and displays fine if I bind a dataform to it. But the results aren't what I want. What I want to accomplish is to have certain fields and display them with a label with the metadata instead of writing out what each field is. I don't want to add the AutoGenerateField:=False to most all of them either. Is this possible using a combination of a label and textbox or individually adding datafield controls to a dataform?  This is all going to be ready only too.

Something Like this:
<sdk:Label Target="{Binding ElementName=CLText}"/>
 <TextBox Text="{Binding Claim}"  Name="CLText"/>


And here's a sample of my metadata
         <Display(Name:="Claim Number ")>
       Public Property Claim As String
        
       <DisplayName("City State Zip")>
       Public Property CSZ As String
 
       <Display(Name:="Customer Primary Address")>
       Public Property CustAddy1 As String

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 21 Sep 2011, 01:35 PM
Hello Trevor,

Unfortunately, we could not understand which of Telerik's controls are you using.

Could you please elaborate how is this question related to our controls? We would be glad to answer any questions that are particularly related to the controls that we offer.

Best wishes,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Trevor
Top achievements
Rank 1
answered on 21 Sep 2011, 02:46 PM
    Well I asked my question if it was possible without specifically using a telerik control. But I also attempted it this way using the raddataform. This correctly displays the data, but does not display labels.

I just pasted text as I keep getting an XML error trying to use the 'Format Code Block'

<DataTemplate x:Key="MyTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <telerik:DataFormDataField DataMemberBinding="{Binding CSZ}"/>
                <telerik:DataFormDataField Grid.Column="1" DataMemberBinding="{Binding Claim}" />
                </Grid>
        </DataTemplate>
   
<telerik:RadDataForm  ItemsSource="{Binding ElementName=ProjectData,Path=Data}" CurrentItem="{Binding}"  AutoGenerateFields="False" ReadOnlyTemplate="{StaticResource MyTemplate}"/>



            

0
Pavel Pavlov
Telerik team
answered on 26 Sep 2011, 03:59 PM
Hi Trevor,

In the context of RadDataForm - in short - if you leave it to create the fields for you , it will respect the data annotation attributes. If you specify your own fields in XAML and set AutoGenerateFields to false, the responsibility of setting the label text would be yours.

All the best,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
General Discussions
Asked by
Trevor
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Trevor
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or