Datatemplate Triggers


Zeeshan Amjad's Blog

Sometime we need to display different values on user element than what is stored in corresponding data bind element. Such as we may store the status code in the form of integer or enum representing different states, but display some user defined string. IValueConverter is the natural choice in this situation. You can see the usage of IValueConverter here.

Alternatively we can do the same thing in XAML only with the help of DataTemplate Trigger. Let’s see we have a product class that have its name, code and status. Code is stored in the form of integer, but we want to display some user define string.

Code Snippet
    publicclassProduct
    {
        publicstring Name { get; set; }
        publicstring Code { get; set; }
        publicint Status { get; set; }
    }

We want to display this…

View original post 560 more words