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 }; // as you see, if a rectangle is added,
// the just above DropShadowEffect code should be worked.
Grid_Timeline.Children.Add(rectangle_timeline); }
xaml code-
<Grid x:Name="Grid_Timeline" ScrollViewer.VerticalScrollBarVisibility="Auto" UseLayoutRounding="True" Width="1159" HorizontalAlignment="Left" VerticalAlignment="Top" SnapsToDevicePixels="True"></Grid>
I dynamically add many Rectangles with above simple code as shown image.
However, sometimes, randomly, there're rectangles without DropShadowEffect like yellow rectangles and 1 blue rectangle at the lowest.
As you see the code, if a rectangle is added, the code for DropShadowEffect should have to be worked.
When I tested case 2, case 3, there're also always same(specific) rectangles without shadow.
I think there might be some funtionality for better performance of WPF like virtualization functionality of stackpanel.
There're around 100 rectangles which many of them look as one rectangle together.
Drawing too many rectangles is the reason?
I'm wondering why this is happening.
Thank you !
↧
DropShadowEffect is sometimes missing when dynamically adding many controls
↧