question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Button in ListBoxItem not firing event

See original GitHub issue

Hello, I am trying to place a button inside a ListViewItem like this:

<ListBox FontSize="13" Items="{Binding Path=SelectedFPGA.Connections}" SelectedItem="{Binding Path=SelectedFPGA.SelectedConnection, Mode=TwoWay}" Background="{StaticResource DarkColor}" BorderThickness="0" VerticalAlignment="Stretch">
                <ListBox.ItemTemplate>
                  <DataTemplate>
                    <DockPanel>
                      <TextBlock Text="{Binding Signal}"></TextBlock>
                      <Image Height="18" Source="avares://VHDPlus/Assets/Images/Icons/twotone_link_white_18dp.png"></Image>
                      <TextBlock Text="{Binding Pin}"></TextBlock>                     
                      <Button Height="18" Width="18" Classes="Seperate" DockPanel.Dock="Right" Command="{Binding Seperate}" HorizontalAlignment="Right" ToolTip.Tip="Seperate connection" Margin="0" Padding="0">
                        <Image Height="18" Source="avares://VHDPlus/Assets/Images/Icons/Close_White_16x.png"></Image>
                      </Button>
                    </DockPanel>
                  </DataTemplate>
                </ListBox.ItemTemplate>
</ListBox>

Unbenannt

It shows correcty but I can’t figure out how to get the click event from it. The :pointerover style does not work too so I am guessing that the Listboxitem consumes the click so the button does not fire the event.

I tried experimenting with Z-Index but it didn’t change anything

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
HendrikMennencommented, Aug 23, 2019

I don’t know what is wrong here but in I managed to make it work in a different ListBox so I guess it was my mistake

0reactions
timuniecommented, Apr 6, 2023

@Touhid9814 answering closed issues will most likely not help you. If you have a question you need an advice, please open a new Q&A in discussion or join us on telegram https://t.me/Avalonia

Read more comments on GitHub >

github_iconTop Results From Across the Web

Button event is not triggered from Listbox item template wpf
button event is not triggered in code behind or in viewmodel with command binding. How to fix this? wpf · listbox · buttonclick...
Read more >
dblclick event in listbox not firing - Forums
I have an issue with the dblclick event not firing immediately from my listbox. It does eventually fire if i mash the mouse...
Read more >
[Solved] WPF ListBox itemtemplate and Button press events
Normally with button click events I just chooce listboxitem and then I press its button but now I cant press listbox item because...
Read more >
UWP - ListBox Scroll Mouse Released Event not Found
I have Simple Listbox Inside a Grid ...ScrollBar is working fine, But I need a Event to Raise when ScrollBar Mouse Released Event....
Read more >
Listbox onSelect event does not fire
I want to do it in MVC but I can't figure it out the function isn't called I tried specifing the path but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found