I grabbed some source off Charles Petzold's website and played around with it. There seems to be a problem that when you rotate the layout of a button in a UniformGrid that at an angle of 45 it shrinks below what is required to show all the text. Is this a bug
Copy all the code below to a .xaml file and run it to see the problem:
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
TextBlock.FontSize="18pt" >
<UniformGrid Rows="3" Columns="3" Width="300">
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button">
<Button.LayoutTransform>
<RotateTransform x:Name="rotation" />
</Button.LayoutTransform>
</Button>
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
</UniformGrid>
<StackPanel.Triggers>
<EventTrigger RoutedEvent="StackPanel.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="rotation"
Storyboard.TargetProperty="Angle"
Duration="0:0:10"
From="0" To="360"
RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</StackPanel.Triggers>
</StackPanel>

Button Resizes Incorrectly when changing the angle of it's layout
dabagaalle
ok, I think the Measure/DesiredSize on Button is a little broken because the problem doesn't occur if I replace it with a TextBlock.
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
TextBlock.FontSize="18pt" >
<UniformGrid Rows="3" Columns="3" Width="450">
<Button Content="Button 1234" />
<Button Content="Button 1234" />
<Button Content="Button 1234" />
<Button Content="Button 1234" />
<TextBlock Text="Button 1234" Background="Red">
<TextBlock.LayoutTransform>
<RotateTransform x:Name="rotation" />
</TextBlock.LayoutTransform>
</TextBlock>
<Button Content="Button 1234" />
<Button Content="Button 1234" />
<Button Content="Button 1234" />
<Button Content="Button 1234" />
</UniformGrid>
<StackPanel.Triggers>
<EventTrigger RoutedEvent="StackPanel.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="rotation"
Storyboard.TargetProperty="Angle"
Duration="0:0:10"
From="0" To="360"
RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</StackPanel.Triggers>
</StackPanel>
halebob
Yes I know. I created this example specifically to show the problem I've encountered. If the button is wide enough at angle 0 and angle 90, then I thought it should be wide enough through the whole rotation (so long as it isn't too tall). Maybe I should have tried to produce an example that was a bit more extreme. On the middle button set the Width to 80 to get an idea of what it should look like:
<Button Content="Button" Width="80">
I also notice if you set the width to say 900, that the button appears not wide enough near angle 0, but still I digress. ok, just created a more extreme version of the problem:
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
TextBlock.FontSize="18pt" >
<UniformGrid Rows="3" Columns="3" Width="450">
<Button Content="Button 1234" />
<Button Content="Button 1234" />
<Button Content="Button 1234" />
<Button Content="Button 1234" />
<Button Content="Button 1234">
<Button.LayoutTransform>
<RotateTransform x:Name="rotation" />
</Button.LayoutTransform>
</Button>
<Button Content="Button 1234" />
<Button Content="Button 1234" />
<Button Content="Button 1234" />
<Button Content="Button 1234" />
</UniformGrid>
<StackPanel.Triggers>
<EventTrigger RoutedEvent="StackPanel.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="rotation"
Storyboard.TargetProperty="Angle"
Duration="0:0:10"
From="0" To="360"
RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</StackPanel.Triggers>
</StackPanel>
Hussain Noordin
Hello -
This does seem to be strange behavior; I've filed a bug on the issue.
Jacob Dickinson
I notice the behaviour is different if I replace the middle button with a TextBlock.
These forums are great, they give the lone developer like me a feeling of being part of something, and it feels like Microsoft is really in touch with it's developer community.
WariaReiMasi