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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:52:02+00:00 2026-05-17T15:52:02+00:00

I have a ListBox with an altered datatemplate (it contains a hyperlinkbutton and a

  • 0

I have a ListBox with an altered datatemplate (it contains a hyperlinkbutton and a textbox for each item). I would like the button to not be visible by default, but to turn visible when the mouse is hovered over that particular list box item. The XAML I have tried so far doesn’t work and i can’t figure out why (by doesn’t work I mean it fails to compile).

 <ListBox Name="lstTest">
      <ListBox.Template>
        <ControlTemplate>
          <ListBox ItemsSource="{Binding}">
            <StackPanel >
              <TextBlock Text="{Binding Path=Name}"/>
              <HyperlinkButton Name="hypEdit" Content="Edit" Visibility="Collapsed"   />
            </StackPanel>
            <ListBox.Triggers>
              <EventTrigger RoutedEvent="ListBoxItem.MouseEnter" >
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="hypEdit" Storyboard.TargetProperty="Visibility"
                               From="Collapsed" To="Visible" Duration="0:0:5" AutoReverse="True" RepeatBehavior="Forever" />
                  </Storyboard>
                </BeginStoryboard>
              </EventTrigger>
            </ListBox.Triggers>
          </ListBox>
          </ControlTemplate>
       </ListBox.Template>
     </ListBox>
  • 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-17T15:52:03+00:00Added an answer on May 17, 2026 at 3:52 pm

    What compile error do you get? I can compile it, but I would not expect it to work.

    You seem to have defined the listbox by defining another listbox within its template. Was that intentional? I would have expected the basic item template to look like this (grid optional):

        <ListBox Name="lstTest" ItemsSource="{Binding}>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <StackPanel VerticalAlignment="Top">
                            <TextBlock Text="{Binding Name}"/>
                            <HyperlinkButton Content="Edit" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    

    Below is a complete working example of what I think you were after:

    <UserControl
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:System="clr-namespace:System;assembly=mscorlib" 
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
        xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
        x:Class="SilverlightApplication1.SilverlightTrigger"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
    
        <Grid x:Name="LayoutRoot" Background="White">
            <ListBox VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ItemsSource="{Binding}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.Resources>
                                <Storyboard x:Name="Storyboard1">
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="hypEdit">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0.5">
                                            <DiscreteObjectKeyFrame.Value>
                                                <Visibility>Visible</Visibility>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                                <Storyboard x:Name="Storyboard2">
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="hypEdit">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0.5">
                                            <DiscreteObjectKeyFrame.Value>
                                                <Visibility>Collapsed</Visibility>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </Grid.Resources>
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="MouseEnter">
                                    <ei:ControlStoryboardAction Storyboard="{StaticResource Storyboard1}"/>
                                </i:EventTrigger>
                                <i:EventTrigger EventName="MouseLeave">
                                    <ei:ControlStoryboardAction Storyboard="{StaticResource Storyboard2}"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                            <StackPanel VerticalAlignment="Top">
                                <TextBlock TextWrapping="Wrap" Text="{Binding Name}" d:LayoutOverrides="Width"/>
                                <HyperlinkButton x:Name="hypEdit" Content="Edit" d:LayoutOverrides="Width" Visibility="Collapsed"/>
                            </StackPanel>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
    </UserControl>
    

    Feel free to tweak to your own requirements.

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

Sidebar

Related Questions

I have listbox, button, and textbox controls in a Windows application. How can I
I have a listbox bound to a collection. I would like the ListBox to
I have a listbox that in which every item is represented using a textbox.
A have listbox <ListBox> <ListBox.ItemTemplate> <DataTemplate> <DockPanel> <Button Content={Binding name_trainer} Tag={Binding idPersonTrainer} DockPanel.Dock=Top HorizontalAlignment=Center>
I have a ListBox that contains a number of User items that are DataTemplate
I have a ListBox that when in focus, and when I have an item
I have a listbox, and I have the following ItemTemplate for it: <DataTemplate x:Key=ScenarioItemTemplate>
I have this ListBox which is bound to an ObservableCollection. Each object in the
I have a listbox with a datatemplate for the items. The problem is that
I have a snippet to create a 'Like' button for our news site: <iframe

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.