简体   繁体   中英

WPF Extended property grid code behind customization

I am using an Extended Toolkit propertyGrid . I need to customize it according to the user defined language preference. From this tutorial I have seen that the display name and other features can be hard-codedly changed.

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 }

}

But I need to do it on the runtime! Thank you for your help

You can customize those things in XAML.

Example for this class:

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

Change the displaying of Property1 :

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

In XAML you can dynamically bind the values instead of using static strings if you need something runtime dependent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM