Databind Resource File in XAML

前端 未结 2 901
Happy的楠姐
Happy的楠姐 2021-01-17 18:31

For localization I\'m using the Resource-file (.resx files) functionality in .NET, but I\'m wondering if there\'s a smart way to databind the various localization properties

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-17 19:02

    Very similar to what Geek proposed, but even a bit easier I think:

    Create a class in the same assembly, which inherits the resources file and exposes a public constructor, then use this class instead.

    public class ResourcesProxy : Properties.Resources
    {
        /// 
        /// resolves the problem of internal constructor in resources.designer.cs
        /// in conjunction with xaml usage
        /// 
        public ResourcesProxy() : base()
        {
        }
    }
    

提交回复
热议问题