I have a StackPanel in which I wish to place images that are 100 x 100 pixels, in a vertical orientation. One of the images is is a bit taller than 100 pixels, it's about 140. A portion of the top 20 pixels and bottom 20 pixels of the image are transparent. I wish to add that image into the StackPanel, along with the other images, such that the non-transparent portions at the top of the image overlap the images that are above and below it in the StackPanel.
Can this be achieved? I am using code similar to below to add an image to the StackPanel:
private void Button_Click(object sender, RoutedEventArgs e) { var bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(@"C:\SomeFolder\Images\image.png"); bitmap.DecodePixelWidth = 100; bitmap.EndInit(); UIElement image = new Image { Source = bitmap, Margin = new Thickness(0), Stretch = Stretch.None }; StackPanel1.Children.Add(image); }