2

Here goes my code:

<ControlTemplate TargetType="{x:Type ToggleButton}">
    <Border x:Name="Chrome">
        <Grid x:Name="Arrow">
            <Grid.Background>
                <DrawingBrush Viewport="0,0,4,4" Viewbox="0,-0.4,16,16" ViewboxUnits="Absolute">
                    <DrawingBrush.Drawing>
                        <GeometryDrawing x:Name="ArrowDrawing">
                            <GeometryDrawing.Geometry>
                                <PathGeometry>
                                    <PathFigure StartPoint="1,1" IsClosed="True">
                                        <LineSegment Point="2,2.45"/>
                                        <LineSegment Point="3,1"/>
                                        <LineSegment Point="2,1.75"/>
                                    </PathFigure>
                                </PathGeometry>
                            </GeometryDrawing.Geometry>
                        </GeometryDrawing>
                    </DrawingBrush.Drawing>
                </DrawingBrush>
            </Grid.Background>
        </Grid>
    </Border>
    <ControlTemplate.Triggers>
        <Trigger Property="IsEnabled" Value="False">
            <Setter Property="Brush" TargetName="ArrowDrawing" Value="{StaticResource DisabledForecolor}"/>
        </Trigger>
    </ControlTemplate.Triggers>
</ControlTemplate>

So when the trigger triggers (on compile time), I got the error:

Cannot find the Trigger target 'ArrowDrawing'. (The target must appear before any Setters, Triggers, or Conditions that use it.)

How do I actually access that GeometryDrawing named ArrowDrawing from the trigger?

AgentFire
  • 8,944
  • 8
  • 43
  • 90

2 Answers2

3

Actually there is two ways to achieve this, one is using a binding:

Storyboard.Target="{Binding ElementName=ContentPopup}"

and the other one is to use a XAML internal reference:

Storyboard.Target="{x:Reference Name=ContentPopup}"

the same answer is here!

Community
  • 1
  • 1
aledustet
  • 1,003
  • 2
  • 14
  • 39
2

This post might help

There is a way to solve this, though, by using data binding. With a Binding, you can find your way out of the brush to an element, and then the Setter can target that element.

Mark Staff
  • 721
  • 3
  • 6