<Window x:Class="WpfApplication1.Window23" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <StackPanel Orientation="Vertical"> <Canvas x:Name="Outer" Height="500" Width="500" Background="AliceBlue"> <Canvas x:Name="Main" Height="200" Width="200" Background="Red" Canvas.Top="200" ClipToBounds="True" > <Canvas.RenderTransform> <RotateTransform Angle="345" /> </Canvas.RenderTransform> <Canvas x:Name="Contained" Height="300" Width="300" Background="Yellow" Canvas.Top="50" Canvas.Left="50"> <Canvas.RenderTransform> <RotateTransform Angle="345"/> </Canvas.RenderTransform> </Canvas> </Canvas> </Canvas> <Border BorderBrush="Black" BorderThickness="2" Width="96" Height="96"> <Viewbox x:Name="VBox" > </Viewbox> </Border> <Button Click="Button_Click">Thumbnail it</Button> </StackPanel> </Window>Code:
using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace WpfApplication1 { public partial class Window23 : Window { public Window23() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { Outer.Children.Remove(Main); Main.LayoutTransform = Main.RenderTransform; Main.RenderTransform = Transform.Identity; VBox.Child = Main; } } }This does what I want. However if ClipToBounds is not set on Main then the sizing is obviously wrong. Whats the simplest way of getting this right?