2010-07-22 37 views
1

這裏是我的DataFormDataform.EditTemplate使用顯示字符串

<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> 

的一部分,而不是明確指定標籤「資本成本」,我想用顯示數據我有底層類型

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; 
      } 
     } 

的描述結轉很好的接口,但我很困惑儘可能的名稱去

謝謝!

回答

0

您應該定義一個IValueConverter,它將您的屬性作爲輸入並返回DisplayAttribute的值。 Here是一個使用標準DisplayNameAttribute類似的例子。