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 5956345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:14:37+00:00 2026-05-22T18:14:37+00:00

I have four visual states defined each affecting different child controls within the same

  • 0

I have four visual states defined each affecting different child controls within the same silver-light control.
Is it possible for me to create other visual states which invoke a combination of these others?

So if I have Visual_Group_1, Visual_Group_2, Visual_Group_3, Visual_Group_4

  1. Is it possible to make, say a
    Visual_Comb_1 group which uses the
    states in Visual_Group_1 and
    Visual_Group_3?
  2. Then make another one called Visual_Comb_2 which uses Visual_Group_4 and Visual_Group_3?

I’m happy to implement a solution in xaml or codebehind or a combination of both.
The alternative I’m looking at currently involves tonnes of code copy+paste and I’m not too keen to do that.

Some more detail per request:

This is what I roughly have right now:

<VisualState x:Name="State1">
    <ColorAnimation Storyboard.TargetName="Path1"
                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                    To="Blue" Duration="0:0:0.5" />
    // fade out the rest of the paths...
    <ColorAnimation Storyboard.TargetName="Path2"
                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                    To="#00000000" Duration="0:0:0.5" />
    <ColorAnimation Storyboard.TargetName="Path3"
                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                    To="#00000000" Duration="0:0:0.5" />
    <ColorAnimation Storyboard.TargetName="Path4"
                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                    To="#00000000" Duration="0:0:0.5" />
</VisualState>

<VisualState x:Name="State2">
    <ColorAnimation Storyboard.TargetName="Path3"
                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                    To="Red" Duration="0:0:0.5" />
    // fade out the rest of the paths...
    <ColorAnimation Storyboard.TargetName="Path2"
                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                    To="#00000000" Duration="0:0:0.5" />
    <ColorAnimation Storyboard.TargetName="Path1"
                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                    To="#00000000" Duration="0:0:0.5" />
    <ColorAnimation Storyboard.TargetName="Path4"
                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                    To="#00000000" Duration="0:0:0.5" />
</VisualState>

<VisualState x:Name="State3">
    <ColorAnimation Storyboard.TargetName="Path4"
                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                    To="Pink" Duration="0:0:0.5" />
    // fade out the rest of the paths...
    <ColorAnimation Storyboard.TargetName="Path2"
                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                    To="#00000000" Duration="0:0:0.5" />
    <ColorAnimation Storyboard.TargetName="Path1"
                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                    To="#00000000" Duration="0:0:0.5" />
    <ColorAnimation Storyboard.TargetName="Path3"
                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                    To="#00000000" Duration="0:0:0.5" />
</VisualState>

My objective is to have a control which when you click on cycles from state1 to state3, each state fades in a different path while fading out the other paths. My problem is that there is a tonne of copy+paste in the ‘fade out the rest of the paths’ section, so if I wanted to add a Path5 it would mean adding it to every single visual state already defined, or if I wanted to change the fadeoff colour or animation I would have to do it to every visual state.

  • 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-22T18:14:38+00:00Added an answer on May 22, 2026 at 6:14 pm

    Thanks for providing the XAML. This is how I would tackle the problem.

    First off, create the VisualStates individually for each Path. (I would recommend using a Style instead to save you re-coding a very similar VisualState into each Path, but I’m not familiar enough with them to know if you can apply different colours to each.)

    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="Path1States">
            <VisualState x:Name="Activate">
                <Storyboard>
                    <ColorAnimation Storyboard.TargetName="Path1"
                                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                                    To="Blue"
                                    Duration="0:0:0.5" />
                </Storyboard>
            </VisualState>
            <VisualState x:Name="Deactivate">
                <Storyboard>
                    <ColorAnimation Storyboard.TargetName="Path1"
                                    Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                                    To="#00000000"
                                    Duration="0:0:0.5" />
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
        <VisualStateGroup x:Name="Path2States">
            <!-- ... etc ... -->
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    

    Now, create a List in the code-behind that contains each of the related objects, and then right your own GoToState function such that it turns on the in state for one object, and calls the off state for the rest.

    List<Path> pathList;
    
    public Page() // constructor
    {
        InitializeComponent();
        pathList = new List<Path>();
        pathList.Add(Path1);
        // and so forth
    }
    
    // Call this function when you want to change the state
    private void ActivatePath(Path p)
    {
        foreach (Path listItem in pathList)
        {
            // If the item from the list is the one you want to activate...
            if (listItem == p)
                VisualStateManager.GoToState(listItem, "Activate", true);
            // otherwise...
            else
                VisualStateManager.GoToState(listItem, "Deactivate", true);
        }
    }
    

    If I were better at XAML and styling I might have a cleaner way of creating the VisualStates. However, my forte is more on the logic and coding side. That being said, it’s much cleaner that writing out the same VisualState four or five times! 🙂
    Hope this helps!

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

Sidebar

Related Questions

I have four Silverlight 4 apps, each in their own Visual Studio project, for
We have four public websites running on the same database with different schema(Oracle). All
I have a Visual Studio solution with four C# projects in it. I want
I have four tables containing exactly the same columns, and want to create a
I have four different lists. headers , descriptions , short_descriptions and misc . I
I have four UINavigationControllers assigned each to a tab in a UITabBarController. Each UINavigationController
I have four fieldsets of checkboxes. Each fieldset is a timeslot (12-1, 1-2, 2-3,
I have four controls; three DropDownList boxes and regular list box. I am gathering
I have four arrays(array1..4) each containing four strings e.g var array1 = ['array1item1', 'array1item2',
I have four UIGestureSwipeRecognizers registered (one for each direction), and they work as intended

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.