Last active
February 14, 2019 03:36
-
-
Save Spraynard/44ff6c24c93d6a0469cb411395579b53 to your computer and use it in GitHub Desktop.
Inserting Image control as a child of BlockUIContainer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Windows.Controls; | |
using System.Windows.Documents; | |
... | |
FileInfo imgInfo = new FileInfo(path_to_img) | |
// Control type | |
Image myImage = new Image(); | |
BitmapImage bitmapImg = new BitmapImage(); | |
bitmapImg.BeginInit() | |
bitmap.UriSource = new Uri(imgInfo.FullName); | |
bitmap.EndInit(); | |
myImage.Source = bitmapImg; | |
// Changing our rotation transform's origin from top left to center of image | |
transform.CenterX = myImage.ActualWidth / 2; | |
transform.CenterY = myImage.ActualHeight / 2; | |
// Applying transform on image control | |
myImage.RenderTransform = transform; | |
// Create our BlockUIContainer | |
BlockUIContainer container = new BlockUIContainer(); | |
container.Child = myImage; | |
// Insert container with image into the document. | |
FlowDocument doc = new FlowDocument(); | |
doc.Blocks.Add(container); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment