title: Draw shadow on image while drawing on DrawingContext
body: <p>I draw an image in OnRender method of my custom FrameworkElement. I would like to draw a shadow of this image as well. I need to do this in code, and I would not like to use DropShadowBitmapEffect because it is obsolete. How can I achieve this?</p>
  
  <pre><code>    public class MyDrawingView : FrameworkElement
      {
          protected override void OnRender(System.Windows.Media.DrawingContext dc)
          {
               drawImagesOnDrawingContext(dc);
          }
  
          public RenderTargetBitmap getBitmap()
          {
              DrawingVisual dv = new DrawingVisual();
              using (DrawingContext dcMine = dv.RenderOpen())
              {
                  drawImagesOnDrawingContext(dcMine);
                  dcMine.Close();
              }
              RenderTargetBitmap rtb = new RenderTargetBitmap(200, 200, 96, 96, PixelFormats.Pbgra32);
              rtb.Render(dv);
              return rtb;
          }
  
          private void drawImagesOnDrawingContext(System.Windows.Media.DrawingContext dc)
          {
              //how to draw shadow on bi?
              BitmapImage bi = new BitmapImage(new Uri(@"D:\mytemp\img1.jpg"));
              dc.DrawImage(bi, new Rect(50, 50, 100, 100));
  
              //how to draw shadow on bi1
              BitmapImage bi1 = new BitmapImage(new Uri(@"D:\mytemp\img2.jpg"));
              dc.DrawImage(bi1, new Rect(30, 30, 100, 100));
          }
  
      }
  </code></pre>
  
  <p>Note that the solution suggested by SvenG below, to add an effect to the underlying element, doesn't work for me because it gives a shadow to the whole element, not the individual images I draw. For example, if I were to have two overlapping DrawImage, the suggested solution will draw shadow considering the whole. The shadow of upper image will not be drawn on the lower image. </p>
  
  <p>Additionally, I want to create a bitmap using the getBitmap function as shown above to export the drawn image with the shadows.</p>