WPF Dictionary Binding failure is very slow

前端 未结 3 969
感情败类
感情败类 2021-01-07 02:39

I have most of the Label objects in my app bound such that they can be replaced from a webservice.

I store my replacements in a Dictionary. The repla

3条回答
  •  逝去的感伤
    2021-01-07 03:10

    If you have the option to, I would change your IDictionary implementation to one that returns null and instead use TargetNullValue (or even be IDictionary and return DependencyProperty.UnsetValue if you still use FallbackValue):

    public class PassthruDictionary : IDictionary
    {
        private Dictionary instance;
    
        // ... other stuff
    
        public TValue this[TKey key]
        {
            get
            {
                TValue value;
                if (instance.TryGetValue(key, out value))
                {
                    return value;
                }
                else
                {
                    return default(TValue);
                }
            }
            // ... more
        }
    }
    

提交回复
热议问题