dropshadoweffect

C# WPF) DropShadowEffect is sometimes missing when dynamically adding a control

不羁岁月 提交于 2019-12-08 17:16:52
问题 foreach (DataRow dr in dt.Rows) { Rectangle rectangle_timeline = new Rectangle(); rectangle_timeline.Height = 19; rectangle_timeline.Cursor = Cursors.Hand; rectangle_timeline.Effect = new DropShadowEffect { Color = new Color { A = 255, R = 0, G = 0, B = 0 }, Direction = 315, ShadowDepth = 5, Opacity = 1 }; Grid_Timeline.Children.Add(rectangle_timeline); } I dynamically add a Rectangle with above simple code as shown image. However, sometimes, randomly, there're rectangles without