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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:21:15+00:00 2026-05-16T10:21:15+00:00

I have a listbox with a datatemplate for the items. The problem is that

  • 0

I have a listbox with a datatemplate for the items.
The problem is that selecting an item doesn’t work by just clicking anywhere on the item; I have to click on a specific sub-element for it to actually work.

My item has an image and a textblock.
If I hover the mouse over the image or text-block, I actually see the hover-effect.
If I hover the mouse over any of the ’empty’ space of the item, no hover effect (and no selection when I click there).

Example image : http://i33.tinypic.com/wvtleg.png

If I click on (or hover over) the actual text or the image it works fine,
but if i hover my mouse in the empty areas (I’ve drawn a red line around it :)) the listbox doesn’t respond.

How do I get the listbox hovering / clicking to respond to clicking anywhere in the item’s space ?

For completeness here is my Listbox + template:

<ListBox Grid.Row="1"
  ItemsSource="{Binding Path=CreatableOutputWindows, Mode=OneWay}" Height="Auto"
  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
  Margin="8,8,8,8"
  Name="listBox1" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
  <ListBox.ItemTemplate>
    <DataTemplate>
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="84"/>
          <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Border Margin="5" BorderBrush="Black" BorderThickness="2">
          <Image Source="{Binding Path=Image}" Stretch="Fill" Width="80" Height="50" />
        </Border>
        <StackPanel Grid.Column="1" Margin="5">
          <StackPanel Orientation="Horizontal" TextBlock.FontWeight="Bold">
            <TextBlock Text="{Binding Path=Name}" />
          </StackPanel>
        </StackPanel>
      </Grid>
    </DataTemplate>
  </ListBox.ItemTemplate>
</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-16T10:21:16+00:00Added an answer on May 16, 2026 at 10:21 am

    As Quartermeister pointed out – you need to set the Background of the Grid – but you also need to set the following style in your resources as ListBoxItems’ HorizontalContentAlignment is set to Left by default. (It isn’t enough to set it on the ListBox)

    <ListBox.Resources>
        <Style TargetType="{x:Type ListBoxItem}">
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        </Style>
    </ListBox.Resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListBox that contains a number of User items that are DataTemplate
I have a ListBox which uses a DataTemplate to render databound items. The XAML
So I have this Xaml inside a ListBox Item Template: <ListBox.ItemTemplate> <DataTemplate> <Grid Height=22
I have a wpf listbox that implements a DataTemplate that contains a TextBlock. <local:BooleanToFontColorConverter
I have a DataTemplate that is used by a listbox: <local:BooleanToFontColorConverter x:Key=boolToFontColor /> <DataTemplate
I have a listbox that has a datatemplate which contains multiple text boxes. I
I have a problem with the selection of items in a Listbox, when the
I have a typical MVVM setup of Listbox and vm + DataTemplate and item
I have a listbox with a DataTemplate for the items. Inside my template, I
I have a WPF listbox with custom items. Each item is a user control

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.