Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: Dynamic attribute to change DescriptionAttribute in PropertyGrid of CollectionEditor

$
0
0
I am using attributes to define the Description, Category and Display name of properties that populate a PropertyGrid (within a CollectionEditor).

Is there any way to modify these attributes at run time such that they display different values? For instance, one of my properties is Temperature, for which I would like the Description to display "Enter temperature (°C)" if the user has selected one unit system and "Enter temperature (°F)" if a different unit system is selected.

Code for the property is shown below:
<DescriptionAttribute("Enter temperature (°C)."), _
         CategoryAttribute("Physical properties"), _
         DisplayName("Temperature")>
        Property Temperature As Double
            Get
                Return myTemperature
            End Get
            Set(ByVal value As Double)
                myTemperature = value
            End Set
        End Property
If I try and put a variable in the argument to DescriptionAttribute I get a 'Constant expression is required' error.

If this is not possible, is there another way of achieving the same effect?

Many thanks for any help.

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>