Patrick
Patrick

Reputation: 2593

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

Upvotes: 0

Views: 293

Answers (1)

grek40
grek40

Reputation: 13458

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.

Upvotes: 0

Related Questions