2

Basically, I have a FooControl (I did not set the Height/Width explicitly) added to a Grid.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>
    <FooControl x:Name="HWFoo" Content="HelloWorld" Grid.Row="0">
        <FooControl.RenderTransform>
            <TransformGroup>
                <RotateTransform Angle="270" />
                <TranslateTransform Y="{Binding ActualWidth, ElementName=HWFoo}" />
            </TransformGroup>
        </FooControl.RenderTransform>
    </FooControl>
</Grid>

But, the problem now is that the FooControl fills up the entire row and when it's transformed it looks quite bizarre (because of it's height/width).


FooControl is a custom control. So do I do something with the ArrangeOverride or MeasureOverride? Or am I doing something wrong that can be fixed in XAML.
H.B.
  • 166,899
  • 29
  • 327
  • 400
michael
  • 14,844
  • 28
  • 89
  • 177

3 Answers3

5

1 - Use LayoutTransform
2 - Set HorizontalAlignment to Left or Right to prevent stretching

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>
    <FooControl x:Name="HWFoo" Content="HelloWorld" Grid.Row="0" HorizontalAlignment="Left">
        <FooControl.LayoutTransform>
            <TransformGroup>
                <RotateTransform Angle="270" />
                <TranslateTransform Y="{Binding ActualWidth, ElementName=HWFoo}" />
            </TransformGroup>
        </FooControl.LayoutTransform>
    </FooControl>
</Grid>
H.B.
  • 166,899
  • 29
  • 327
  • 400
2

I'm not sure what you mean by 'bizarre', but I'd suggest to try and use LayoutTransform instead of RenderTransform - that's probably the issue.

Due note however that LayoutTransform is significantly slower than RenderTransform.

Elad Katz
  • 7,483
  • 5
  • 35
  • 66