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

  • Home
  • SEARCH
  • 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 7399331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:02:51+00:00 2026-05-29T04:02:51+00:00

Based on some standard web searching, I have narrowed down my problem to this:

  • 0

Based on some standard web searching, I have narrowed down my problem to this: I believe the event that fires my storyboard gets invoked prior to the template being expanded. Thus, names are meaningless, and name references made by the storyboard’s animations are null.

This would not be an issue if I were not working with a ControlTemplate. I could just bind to the event after the layout is updated, then manually invoke it the first time around. Problem solved. However, since this is a ControlTemplate in its own resource dictionary XAML file, I can’t use C# to solve this problem.

(Update: I can definitively say that this is not an ordering issue–in other words, it has nothing to do with having defined the contents before ControlTemplate.Resources or similar. However, similar problems can be caused by such ordering issues, so this matter is worth investigating if you are encountering similar problems. See one of the answers below made before this update for a more detailed explanation.)

Then again, I could be on the wrong track entirely. This is just my understanding of what is going on behind the curtain. So that you can judge for yourself, here is the actual exception:

System.InvalidOperationException:
{“‘PART_UnderlineBrush’ name cannot be found in the name scope of ‘System.Windows.Controls.ControlTemplate’.”}

Here is the style/template for reference, with all the extra stuff (storyboards, properties, etc.) removed.

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="MetroTabItem" TargetType="{x:Type TabItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Border>
                        <Border.BorderBrush>
                            <!-- This is the element that I need to reference, but I am unable to do so. -->
                            <SolidColorBrush Color="#00ffffff" x:Name="PART_UnderlineBrush" />
                        </Border.BorderBrush>
                        <ContentPresenter Content="{TemplateBinding Header}"
                                          ContentTemplate="{TemplateBinding HeaderTemplate}" />
                    </Border>
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="SelectTab">
                            <!-- This is the animation that will always fail, due to the name reference. -->
                            <ColorAnimation BeginTime="0:0:0"
                                            Duration="0:0:0.5"
                                            Storyboard.TargetProperty="Color"
                                            Storyboard.TargetName="PART_UnderlineBrush"
                                            To="#ddffffff" />
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <ControlTemplate.Triggers>
                        <EventTrigger RoutedEvent="Selector.Selected">
                            <BeginStoryboard Name="BeginSelected" Storyboard="{StaticResource SelectTab}" />
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
  • 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-29T04:02:52+00:00Added an answer on May 29, 2026 at 4:02 am

    I don’t know if this will do exactly what you want, but if you replace your EventTrigger with a Trigger for the IsSelected property of the TabItem it might work:

    <ControlTemplate.Triggers>
        <Trigger Property="IsSelected" Value="True">
            <Trigger.EnterActions>
                <BeginStoryboard Name="BeginSelected" Storyboard="{StaticResource SelectTab}" />
            </Trigger.EnterActions>
        </Trigger>
    </ControlTemplate.Triggers>
    

    There does seem to be some timing issue going on with the original code. The Selector.Selected event seems to be fired before the control has loaded.

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

Sidebar

Related Questions

Based on some answers to this question it appears that +alloc does some behind-the-scenes
I have some classes that will do something based on some conditions . The
I have a Person Class and based on some help I received in this
I've been working with a developer on a web-based application. I have some experience
I have a web app which has standard things for learning based app like
I have a HttpHandler that generates a Google sitemap based on my asp.net web.sitemap.
I have the following requirement: Based on some user input, I need to generate
I want to invalidate sessions of users based on some Event. I store their
I have a library I am creating based on some WSDL/XSD definitions. I am
My application requires events to be fired based on some specific activities that happen.

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.