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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:11:03+00:00 2026-05-15T01:11:03+00:00

I have a stackpanel that has a dynamic amount of images that are added

  • 0

I have a stackpanel that has a dynamic amount of images that are added programatically, Is there a way I can set a hover/click effect programatically on these images. I would like for the image to “glow” when clicked. How do i do that in silverlight? I’ve noticed the Image.Effect property, but I’m not really sure how to use it.

  • 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-15T01:11:04+00:00Added an answer on May 15, 2026 at 1:11 am

    What you need to do is create a new usercontrol with the image control inside with the visualstates attached to it. This way, you can dynamically add the usercontrol to the stackpanel and have the animations being called without attaching them by events from your main app.

    I used the DropShadowEffect on the Image.Effect to create a pulsating animation.

    For eg. This is inside your usercontrol:

    XAML

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="ImageState">
                <VisualState x:Name="NormalImageState">
                    <Storyboard>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)" Storyboard.TargetName="image1" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="GlowingImageState">
                    <Storyboard AutoReverse="True">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)" Storyboard.TargetName="image1">
                            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="20"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:2" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>                        
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    
        <Image Name="image1" MouseEnter="image1_MouseEnter" MouseLeave="image1_MouseLeave" >
            <Image.Effect>
                <DropShadowEffect Color="Red" BlurRadius="0" ShadowDepth="0"/>
            </Image.Effect>
        </Image>
    

    C#

        public ImageSource ImageSource
        {
            get;
            set
            {
                image1.Source = value;
            }
        }
        private void image1_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            VisualStateManager.GoToState(this, "GlowingImageState", true);
        }
    
        private void image1_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            VisualStateManager.GoToState(this, "NormalImageState", true);
        }
    

    Then you can add this usercontrol to your stack panel like so:

     MyUC uc= new MyUC(); //control we just created
     uc.ImageSource = sourceOfImg; //the source of the intended image
     myStack.Children.Add(uc); //adding it to the stackpanel.
    

    Tell me if this works.

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

Sidebar

Related Questions

In WPF 3.5 (with SP1), I have simply StackPanel that I would like to
I have a ListBox with a StackPanel that contains an image and label. <ListBox.ItemsPanel>
I have a WPF StackPanel that looks like this: (some attributes removed that don't
I have a windows phone 7 project with a page that has the following
I have a silverlight control that has a Frame on it. I want to
I currently have a Combo box that has data that is bind from a
In this hypothetical example, imagine I have an object FooSet that has five properties
I have a stack panel inside of an expander panel that I programaticaly adds
I have a combo box with the following DataTemplate: <DataTemplate x:Key=ComboBoxDataTemplate> <StackPanel> <TextBlock Text={Binding
I have this: <ListBox x:Name=PART_lstAttributes Grid.Row=1 Style={StaticResource GlossyBlackListBox}> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock x:Name=txtAttributeName Text={Binding

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.