Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Cannot find governing FrameworkElement or FrameworkContentElement for target element

$
0
0
Hi

I'm having a problem with the following control template

<Style TargetType="{x:Type local:SymbolFeature}" > 
    <Setter Property="Template">  
        <Setter.Value> 
            <ControlTemplate TargetType="{x:Type local:SymbolFeature}">  
                <Border x:Name="border">  
                    <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="1" Stroke="Black" Width="40" Height="20" RenderTransformOrigin="0.5, 0.5">  
                        <Ellipse.RenderTransform> 
                            <TransformGroup> 
                                <TranslateTransform X="{Binding OffsetX, RelativeSource={RelativeSource TemplatedParent}}" 
                                                    Y="{Binding OffsetY, RelativeSource={RelativeSource TemplatedParent}}" /> 
                                <RotateTransform Angle="{Binding Angle, RelativeSource={RelativeSource TemplatedParent}}" /> 
                            </TransformGroup> 
                        </Ellipse.RenderTransform> 
                    </Ellipse> 
                </Border> 
                <ControlTemplate.Triggers> 
                    <Trigger Property="Visible" Value="False">  
                        <Setter Property="Visibility" Value="Collapsed" /> 
                    </Trigger> 
                </ControlTemplate.Triggers> 
            </ControlTemplate> 
        </Setter.Value> 
    </Setter> 
</Style> 

In the debugger console, I receive the following debug error:

System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=OffsetX; DataItem=null; target element is 'TranslateTransform' (HashCode=52727599); target property is 'X' (type 'Double')

System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=OffsetY; DataItem=null; target element is 'TranslateTransform' (HashCode=52727599); target property is 'Y' (type 'Double')

System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=Angle; DataItem=null; target element is 'RotateTransform' (HashCode=14347911); target property is 'Angle' (type 'Double')

SymbolFeature derives from Control, and Angle, OffsetX and OffsetY are implemented as Dependency Properties.

There will be plenty of instances of this control in a window, and I worry the error will result in performance costs. I am also the type who hate to see compiler/debugger warnings, as I believe they are warnings for a reason.

How can I get rid of this debugger error? I was hoping I could use TemplateBindings, however, there seems to be some poblems with Inheritance context for the Transforms.

Regards,
Bjørnar

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>