public static System.Windows.Documents.BlockUIContainer getImageBlock(ImageModel imgModel, System.Windows.Documents.FlowDocument doc) { string fileName = AppLib.GetImageFullFileName(imgModel.Source); System.Windows.Controls.Image img = getImage(fileName); if (img == null) { return(null); } double width = (double)imgModel.Width, height = (double)imgModel.Height; if ((height != 0) && (width != 0)) { img.Height = height; img.Width = width; // img.Stretch = System.Windows.Media.Stretch.Fill; } else if ((height == 0) && (width == 0)) { img.Width = doc.PageWidth - doc.PagePadding.Left - doc.PagePadding.Right; } else { if (!height.Equals(.0)) { img.Height = height; } if (!width.Equals(.0)) { img.Width = width; } // img.Stretch = System.Windows.Media.Stretch.Uniform; } img.Stretch = System.Windows.Media.Stretch.Uniform; System.Windows.Documents.BlockUIContainer block = new System.Windows.Documents.BlockUIContainer(img); block.Margin = new System.Windows.Thickness(imgModel.LeftMargin, imgModel.TopMargin, imgModel.RightMargin, imgModel.ButtomMargin); return(block); }