Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 226657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:31:59+00:00 2026-05-11T19:31:59+00:00

I’ve thrown together a template in Expression Blend for a button, and it works

  • 0

I’ve thrown together a template in Expression Blend for a button, and it works alright – until I tab over to it and press the spacebar. I get the following error:

InvalidOperationException
‘[Unknown]’ property does not point to a DependencyObject in path ‘(0).(1).[0].(2)’.

The code is as follows:

    <ControlTemplate x:Key="EmailButton" TargetType="{x:Type Button}">
        <ControlTemplate.Resources>
            <Storyboard x:Key="MouseOverStoryboard">
                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="border" Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                    <SplineColorKeyFrame KeyTime="00:00:00.4000000" Value="#FF55679E"/>
                </ColorAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="UnMouseOverStoryboard">
                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="border" Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                    <SplineColorKeyFrame KeyTime="00:00:00.4000000" Value="#FF92A2D3"/>
                </ColorAnimationUsingKeyFrames>
            </Storyboard>
        </ControlTemplate.Resources>
        <Border x:Name="border" BorderBrush="#FF000000" BorderThickness="2,2,2,2" CornerRadius="4,4,4,4">
            <Border.Background>
                <LinearGradientBrush EndPoint="0.47,-0.01" StartPoint="0.47,0.808">
                    <GradientStop Color="#FF92A2D3" Offset="0"/>
                    <GradientStop Color="#FFFFFFFF" Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Margin="{TemplateBinding Padding}"/>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" TargetName="border" Value="#FF92A2D3"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard x:Name="MouseOverStoryboard_BeginStoryboard" Storyboard="{StaticResource MouseOverStoryboard}"/>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard x:Name="UnMouseOverStoryboard_BeginStoryboard" Storyboard="{StaticResource UnMouseOverStoryboard}"/>
                </Trigger.ExitActions>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

It would seem like either the MouseOverStoryboard or UnMouseOverStoryboard are being fired (The path mentioned in the error seems to match the TargetProperty). I’m not sure why either would fire when pressing the spacebar though… Any suggestions?

EDIT:
Thanks to Ryan Versaw, I tried the following, which now prevents spacebar-clicking from throwing the exception:

            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" TargetName="border">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FF92A2D3" Offset="0"/>
                            <GradientStop Color="#FF92A2D3" Offset="1"/>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </Trigger>

Now the brush type stays consistent (LinearGradientBrush), and there is always 0th GradientStop available.

I’m still curious about one other thing – what is the best way to go about this, considering that this sorta feels like a hack (ex: a third gradient stop is added/animated, then a third GradientStop needs to be added when IsPressed==True).

Thanks for the suggestions! Hopefully this will help someone else, too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:31:59+00:00Added an answer on May 11, 2026 at 7:31 pm

    I’m not sure what the optimal solution would be, but I found one that works.

    Create a LinearGradientBrush in your resources:

    <LinearGradientBrush x:Key="solidBrush">
        <GradientStop Color="#FF92A2D3"/>
    </LinearGradientBrush>
    

    Change your IsPressed trigger to the following (only the Value changes):

    <Trigger Property="IsPressed" Value="True">
        <Setter Property="Background" TargetName="border" Value="{StaticResource solidBrush}"/>
    </Trigger>
    

    This should swap out your entire background for a new one (which is also a LinearGradientBrush).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 368k
  • Answers 368k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer How about: diff -I '^time.*' file1 file2? Please note it… May 14, 2026 at 6:06 pm
  • Editorial Team
    Editorial Team added an answer There's no universal way to do it. First, you'd need… May 14, 2026 at 6:06 pm
  • Editorial Team
    Editorial Team added an answer Here is an implementation of websockets for objective-c http://github.com/esad/zimt May 14, 2026 at 6:06 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.