private void DrawStuff() { // //if (buffer == null) //{ // buffer = new RenderTargetBitmap((int)Background.Width, (int)Background.Height, 96, 96, PixelFormats.Pbgra32); // Background.Source = buffer; // return; //} //using (DrawingContext drawingContext = drawingVisual.RenderOpen()) //{ // drawingContext.DrawRectangle(new SolidColorBrush(Colors.Red), null, new Rect(0, 0, 10, 10)); //} //buffer.Render(drawingVisual); } private void DrawImage() { // // layoutDocumentMapContainer //if (dockPanelMapContainer.ActualWidth <1 || dockPanelMapContainer.ActualHeight < 1 || this.Background == null) //{ // return; //} //using (Bitmap bitmap = new Bitmap((int)dockPanelMapContainer.ActualWidth, (int)dockPanelMapContainer.ActualHeight)) //{ // this.Background.Visibility = Visibility.Visible; // this.Background.Width = (double)bitmap.Width; // this.Background.Height = (double)bitmap.Height; // Graphics graphics = Graphics.FromImage(bitmap); // graphics.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.Blue), new RectangleF(0, 0, (float)(dockPanelMapContainer.ActualWidth - 0), (float)(dockPanelMapContainer.ActualHeight - 0))); // MemoryStream memoryStream = new MemoryStream(); // bitmap.Save(memoryStream, ImageFormat.Png); // memoryStream.Position = 0L; // BitmapImage bitmapImage = new BitmapImage(); // bitmapImage.BeginInit(); // bitmapImage.StreamSource = memoryStream; // bitmapImage.EndInit(); // this.Background.Source = bitmapImage; // graphics.Dispose(); // graphics = null; //} }