【问题标题】:WPF Extended property grid code behind customization自定义背后的 WPF 扩展属性网格代码
【发布时间】:2016-11-30 09:50:22
【问题描述】:

我正在使用Extended Toolkit propertyGrid。我需要根据用户定义的语言偏好对其进行自定义。 从this 教程中,我看到显示名称和其他功能可以硬编码更改。

public class Customer
{
    public int ID { get; set; }

    [ExpandableObject]
    [Category("General settings")]<-------hard coded feature change
    [DisplayName("Nome persona")]<--------hard coded feature change
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public Gender Gender { get; set; }
    public DateTime BirthDate { get; set; }
    public string Phone { get; set; }
}
public enum Gender { Male, Female }

}

但我需要在运行时执行此操作!谢谢你的帮助

【问题讨论】:

    标签: c# .net propertygrid wpf-extended-toolkit displayname-attribute


    【解决方案1】:

    您可以在 XAML 中自定义这些内容。

    这个类的例子:

    public class MyVMEntry
    {
        public string Property1 { get; set; }
        public string Property2 { get; set; }
    }
    

    更改Property1的显示:

    <xt:PropertyGrid SelectedObject="{Binding}" AutoGenerateProperties="True">
        <xt:PropertyGrid.PropertyDefinitions>
            <xt:PropertyDefinition Name="Property1" DisplayName="First Property" Category="Special"/>
        </xt:PropertyGrid.PropertyDefinitions>
    </xt:PropertyGrid>
    

    在 XAML 中,如果您需要一些依赖于运行时的东西,您可以动态绑定值而不是使用静态字符串。

    【讨论】:

      猜你喜欢
      • 2017-11-02
      • 2012-03-08
      • 2013-08-09
      • 2014-11-18
      • 2019-02-04
      • 1970-01-01
      • 2015-07-31
      • 2011-08-17
      • 2016-06-22
      相关资源
      最近更新 更多