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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:24:22+00:00 2026-06-03T12:24:22+00:00

I have a Listbox containing many items. When I hover over an item I

  • 0

I have a Listbox containing many items. When I hover over an item I need to display a rather ‘heavy’ popup. I’m pretty sure that loading the popup for each item is a waste of resources so what I’d like to have is only when I hover over the item I modify the template of the ContentControl within the item to include the Popup. This is what I have so far: (a simplified version) (this code can be pasted into Kaxaml)

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Page.Resources> 

    <ControlTemplate x:Key="WithPopup" TargetType="ContentControl">
      <Grid>
        <ContentPresenter Content="{TemplateBinding Content}" Name="Target" />
        <Popup PlacementTarget="{Binding ElementName=Target}" IsOpen="True" >
            <Border BorderBrush="Red" BorderThickness="1" Background="Pink"> 
                <TextBlock Text="I'd like this to behave like a Popup - not a tooltip!" Margin="10" /> 
            </Border> 
        </Popup> 
      </Grid>
    </ControlTemplate>   
  </Page.Resources>
  <Grid Height="20" Margin="50,50,0,0" Name="ParentGrid">  
    <ContentControl>
      <TextBlock x:Name="TargetControl" Text="Hover over me!"  /> 
      <ContentControl.Style>
        <Style TargetType="ContentControl">
          <Style.Triggers>
            <DataTrigger Binding="{Binding IsMouseOver, ElementName=TargetControl}" Value="True">
              <Setter Property="Template" Value="{StaticResource WithPopup}" />
            </DataTrigger>
          </Style.Triggers>
        </Style>
      </ContentControl.Style>
    </ContentControl>
  </Grid>
</Page>

The problem is that when I try to MouseOver the Popup – it disappears (like a tooltip) because I I’m the mouse is leaving the original ControlTemplate – which causes the template with the Popup to disappear. Any ideas?
Edit: I have codebehind available as well to achieve this (even though I’d prefer xaml)

  • 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-06-03T12:24:25+00:00Added an answer on June 3, 2026 at 12:24 pm

    I have what I think is (at least part of) a solution:
    Instead of changing the ContentControl’s Template via a Trigger, changing the Popup’s
    content with the Trigger seems to work. So instead of loading a complex Popup with a large Visual Tree for each item, I load a simple Popup with no content for each item – and only fill that content when I MouseEnter the ContentControl. Like so:

    <Page
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <Page.Resources>
        <DataTemplate x:Key="popupContent" DataType="{x:Type ContentControl}">
          <Border BorderBrush="Red" BorderThickness="1" Background="Pink"> 
              <TextBlock Text="This is behaving like a Popup now!" Margin="10" /> 
          </Border>
        </DataTemplate>
    
        <ControlTemplate x:Key="WithPopup" TargetType="ContentControl">
          <Grid Name="popupGrid">
            <TextBlock Text="Hover over me!"  />
            <Popup IsOpen="True" > 
                <ContentControl Name="content" />
            </Popup> 
          </Grid>
          <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding IsMouseOver, ElementName=popupGrid}" Value="True"> 
              <Setter Property="ContentTemplate" Value="{StaticResource popupContent}"  TargetName="content" />
            </DataTrigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
    
      </Page.Resources>
      <Grid Height="20" Width="100" HorizontalAlignment="Left" Margin="50,50,0,0">  
        <ContentControl Template="{StaticResource WithPopup}" />
      </Grid>
    </Page>
    

    I’m not quite sure how to measure how much I would gain performance-wise using this method, but I think it seems to make sense. I’d still like to hear any other better ideas.
    Thanks.

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

Sidebar

Related Questions

I have a ListBox containing a group of 'Expander' items, and what I would
I have a listbox containing all the items and a second listbox that will
I want to display a listbox containng list items, I have the following template
I have a ListBox with a rather simple ItemTemplate defined - containing a TextBlock
My problem is rather simple. I have a ListBox, containing Thumnails (Image) <ListBox Name=ListBox_Thumbnails
I have a ListBox containing a large number of items, which are all account
I have a listbox containing some items that have a template. The items are
I have a ListBox in single-selection-mode containing some items. I implemented that the user
I have a listbox containing Users. The datasource is an generic list of the
The Scenario I have a windows forms application containing a MAINFORM with a listbox

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.