DynamicResource color doesn't work for BorderBrush on a Border - Bug?

前端 未结 5 2049
傲寒
傲寒 2020-12-30 09:42

Visual Studio 2010 | .NET/WPF 4.0

I think this might be a WPF bug, but I can\'t seem to find a bug report about it. To cover the possibility that I\'m just missing s

5条回答
  •  滥情空心
    2020-12-30 10:48

    Here is a custom control which you can use in place of the Border. It fixes the problem with the BorderBrush property. It uses Rectangles which work as another answer indicates. Please note that this control will probably not match the performance of using the Border control but it does work, so I suggest only using it where necessary.

    
    
    public sealed class BorderFix : ContentControl
    {
        static BorderFix()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(BorderFix), new FrameworkPropertyMetadata(typeof(BorderFix)));
        }
    }
    

    The fact that we have to do this is pretty ridiculous. Another answer suggests that this bug is fixed in the version of .NET used by Windows 8. I have not tested that but let us hope that is correct. .NET 4.5.51209 exhibits the same problem.

提交回复
热议问题