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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:27:32+00:00 2026-05-17T21:27:32+00:00

I have a listbox whose listboxitem contains, among other things, a button, as follows:

  • 0

I have a listbox whose listboxitem contains, among other things, a button, as follows:

<DataTemplate x:Key="cDataTemplate" DataType="x:Type utils:cd">
    <StackPanel Orientation="Horizontal" Background="Transparent">
        <Button Style="{StaticResource LIButton}" x:Name="CButton" 
                Command="{x:Static this:EditorCommands.RaiseCMenu}" 
                CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}}}">
            <Image Name="Image" Source="icon_c.jpg" Width="33" Height="21"/>
            <Button.ContextMenu>
                <ContextMenu x:Name="ctxtCard">
                    <MenuItem Header="..." Command="{x:Static this:EditorCommands.abc}"/>
                    <MenuItem Header="..." Command="{x:Static this:EditorCommands.def}"/>
                </ContextMenu>
            </Button.ContextMenu>
        </Button>
        <StackPanel Background="Transparent">
            <TextBlock HorizontalAlignment="Left">
...
            </TextBlock>
            <TextBlock HorizontalAlignment="Left">
...
            </TextBlock>
        </StackPanel>
    </StackPanel>
</DataTemplate>

<Style x:Key="cListBoxItemStyle" TargetType="ListBoxItem">
    <Setter Property="ContentTemplate" Value="{DynamicResource cDataTemplate}"/>
    <Setter Property="Background" Value="transparent"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ListBoxItem">
                <Border
                         Name="Border"
...
                         Background="Transparent">
                    <ContentPresenter Name="Content" HorizontalAlignment="Left" VerticalAlignment="Center" Opacity="0.55"/>
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsSelected" Value="true">
                        <Setter TargetName="Border" Property="BorderBrush" Value="Black"/>
                    </Trigger>
                    <Trigger Property="IsSelected" Value="true">
                        <Setter TargetName="Border" Property="BorderThickness" Value="1,1,1,1"/>
                    </Trigger>
                    <Trigger Property="IsSelected" Value="true">
                        <Setter TargetName="Content" Property="Opacity" Value="1.0"/>
                    </Trigger>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="Content" Property="Opacity" Value="1.0"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

When the button in a listboxitem that is not selected is clicked, it fires its command, which raises the context menu in code-behind and selects the button’s parent listboxitem. (The whole point is to raise the context menu on left-click.) But for the life of me, I can’t get the button to fire the command when its parent listboxitem is already selected. Oddly, if the button inside a selected listboxitem is right-clicked, it duly raises its context menu, so the button is receiving clicks.

Thanks in advance!

  • 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-17T21:27:33+00:00Added an answer on May 17, 2026 at 9:27 pm

    Apparently this happens when the selectionmode on a listbox is set to extended. I’ll update this question if I ever find a way around it.

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

Sidebar

Related Questions

I have a listbox, and I have the following ItemTemplate for it: <DataTemplate x:Key=ScenarioItemTemplate>
I have a listbox whose values are generated dynamically. The list box contains months
I have a ListBox that contains a number of User items that are DataTemplate
I have a ListBox whose ItemsPanel I have replaces with a WrapPanel. The WrapPanel
I have a ListBox whose ItemsSource is databound to a list of ints. I'd
I have a ListBox whose ItemsSource is bound to a list of objects. The
I have an ASP.NET page with a listbox whose selection mode is set to
The question says it all. I have a listbox whose rowsource is change programmaticaly.
I don't know what I'm doing wrong here. I have a ListBox whose DataContext
I have a page with two ListBox controls. The page contains a list of

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.