/// <inheritdoc />
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            var binding = new Binding
            {
                Source = Instance,
                Mode   = BindingMode.OneWay,
                Path   = new PropertyPath($"[{_key ?? _themeKey.ToString()}]"),
            };

            var target   = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget;
            var property = target?.TargetProperty as DependencyProperty;

            if (property?.PropertyType == typeof(Color))
            {
                binding.Converter = Converters.BrushToColor;
            }

            return(binding.ProvideValue(serviceProvider));
        }
示例#2
0
文件: Theme.cs 项目: mohsenmou/ui-wpf
 public static object GetResource(ThemeResourceKey resourceKey)
 {
     return(ResourceDictionary.Contains(resourceKey.ToString()) ?
            ResourceDictionary[resourceKey.ToString()] : null);
 }
示例#3
0
 internal static void SetResource(ThemeResourceKey resourceKey, object resource)
 {
     SetResource(resourceKey.ToString(), resource);
 }