views:

26

answers:

1

Hi,

Here is a part of my DataForm

<Grid x:Name="LayoutRoot" Background="White">
    <df:DataForm x:Name="df1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CurrentItem="{StaticResource descriptor}" CommandButtonsVisibility="All" AutoGenerateFields="False" >
        <df:DataForm.EditTemplate>
            <DataTemplate>
                <StackPanel>
                          <df:DataField Label="Capital Cost" >
                        <TextBox Text="{Binding CapitalCost, Mode=TwoWay}" ></TextBox>
                    </df:DataField>

rather than explicitly specifying the Label "Capital Cost", I would like to use the Display data I have in the underlying type

  public class Descriptor     
    {
        [Display(Name = "Capital Cost:", Description = "The negotiated price of the car")]
        public double CapitalCost
        {
            get
            {
                return _CapitalCost;
            }
            set
            {
                if (value > UsMsrp)
                    throw new ArgumentException("Capital Cost must be equal or less than US MSRP");
                _CapitalCost = value;
            }
        }

The description is carried over nicely to the interface, but I'm confused as far as the Name goes

Thanks!

A: 

You should define an IValueConverter that takes your property as input an returns the value of the DisplayAttribute. Here is an example that does something similar using the standard DisplayNameAttribute.

David Lynch