Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Silverlight 4.0 如何在silverlight 4的显示属性中动态设置name属性_Silverlight 4.0_Dynamic_Propertyinfo_Setattribute - Fatal编程技术网

Silverlight 4.0 如何在silverlight 4的显示属性中动态设置name属性

Silverlight 4.0 如何在silverlight 4的显示属性中动态设置name属性,silverlight-4.0,dynamic,propertyinfo,setattribute,Silverlight 4.0,Dynamic,Propertyinfo,Setattribute,我想在任何属性的显示属性中动态地命名属性 考试: [Display(Name = "Test")] public bool Task1 { get { return this.m_Task1; } set { if (value != this.m_Task1) { this.m_Task1 = value; No

我想在任何属性的显示属性中动态地命名属性

考试:

    [Display(Name = "Test")]
    public bool Task1
    {
        get { return this.m_Task1; }
        set
        {
            if (value != this.m_Task1)
            {
                this.m_Task1 = value;
                NotifyPropertyChanged("TaskName");
            }
        }
    }
在这个属性中,我想给name属性动态地表示“Test”,该值将来自数据库。 那么,在生成属性时,如何在显示属性中动态地指定name属性呢? 有人能帮我找到解决办法吗?

试试这个:

[Display(Name = "Tu edad")]
public int Edad
{
  get { bla, bla...; }
  set { bla, bla...; }
}

public void ChangeEdad()
{
  var TheProperty =
    this.GetType().GetProperties().Where(x => x.Name == "Edad").FirstOrDefault();

  object TheAttribute = 
    TheProperty.GetCustomAttributes(typeof(DisplayAttribute), false)[0];

  DisplayAttribute DA = TheAttribute as DisplayAttribute;
  DA.Name = "Your Age";
}
试试这个:

[Display(Name = "Tu edad")]
public int Edad
{
  get { bla, bla...; }
  set { bla, bla...; }
}

public void ChangeEdad()
{
  var TheProperty =
    this.GetType().GetProperties().Where(x => x.Name == "Edad").FirstOrDefault();

  object TheAttribute = 
    TheProperty.GetCustomAttributes(typeof(DisplayAttribute), false)[0];

  DisplayAttribute DA = TheAttribute as DisplayAttribute;
  DA.Name = "Your Age";
}

是否要修改该类的所有实例的显示名称?是否要修改我的实体类的所有属性?是否要修改该类的所有实例的显示名称?是否要修改我的实体类的所有属性。