Is it possible to update DisplayNameAttribute of a property at runtime?

Grids for WPF Forum

Posted 2 years ago by Farouk Bouali
Version: 19.1.4
Avatar

Hello,

I made a custom DisplayNameAttribute class, it will retreive the displayname from txlib resource based on the used culture.

public sealed class DisplayNameByResourceAttribute : DisplayNameAttribute
    {
        public DisplayNameByResourceAttribute(string resourceKey) : base(GetResourceValue(resourceKey))
        {
            ResourceKey = resourceKey;
        }

        public string ResourceKey { get; }

        private static string GetResourceValue(string key)
        {
            return Tx.Text(key);
        }
    }

I want the DisplayName is updated at runtime when the txlib culture changes. Any help with this? 

Comments (1)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Microsoft's DisplayNameAttribute is intended for fixed string values.  Whereas their newer DisplayAttribute (see linked documentation) is intended to pull from the current culture's resources so that it is localizable.  I would suggest using that instead.  We cover that attribute in our documentation on supported attributes too.


Actipro Software Support

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.