Here is the C# code snippet for adding BitMap on Flow Document of WPF. System.Windows.Controls.Image testimage = new System.Windows.Controls.Image(); object o = Properties.Resources.ResourceManager.GetObject("bitmap1"); Bitmap bm = (Bitmap)o; var memoryStream = new MemoryStream(); bm.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Bmp); memoryStream.Position = 0; var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = memoryStream; bitmapImage.EndInit(); testimage.Source = bitmapImage; testimage.Stretch = Stretch.None; testimage.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; Label lblImageName= new Label(); lblImageName.Content = "bitmap1"; StackPanel sp1 = new StackPanel(); sp1.Children.Add(testimage); sp1.Children.Add(lblImageName); dc1.Children.Add(sp1); BlockUIContainer buc = new BlockUIContainer(dc1); flowDoc.Blocks.Add(buc); XAML Code: <Grid>
Learn Tips and tricks, Concepts, Ideas for software development