views:

13

answers:

1

In Silverlight 4: I'm converting a Usercontrol to a templated control. In my Usercontrol I had a RenderTransform

<src:UserControlView.RenderTransform>
    <TransformGroup>
        <ScaleTransform/>
        <SkewTransform/>
        <RotateTransform/>
        <TranslateTransform X="-478" Y="-478"/>
    </TransformGroup>
</src:UserControlView.RenderTransform>

But now I'm in the Controltemplate I get an error message:

Error 5 The attachable property 'RenderTransform' was not found in type 'MyControl'. ...\Themes\Generic.xaml

                <local:MyControl.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform />
                        <SkewTransform />
                        <RotateTransform />
                        <TranslateTransform X="-478"
                                            Y="-478" />
                    </TransformGroup>
                </local:MyControl.RenderTransform>

the local:MyControl is a desperate attempt 'cause I don't know how or where to look. My MyControl inherits from Control en there is a RenderTransform on UIElement so it somehow has to find it right?

A: 

I assume you are just trying to set default Render Transform properties? If so you just want to implement setters in the generic style:

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/client/2007" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:SilverlightApplication1"
>
    <Style TargetType="local:MyControl">
        <Setter Property="RenderTransform">
            <Setter.Value>
                <TransformGroup>
                    <TranslateTransform X="-478" Y="-478" />
                </TransformGroup>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:MyControl">
                    // Your actual template goes here
                </ControlTemplate>
            </Setter.Value>            
        </Setter>
    </Style>
</ResourceDictionary>

If not please show more of your current source/Xaml and I will correct this example.

Enough already
Yes, that sound quite logical :) Sometimes your mind just doesn't wander in that direction.
Michaud