Click on the list in WPF

I can get the button to display and click it in the drop-down list of the combo box, but I can’t get the selected list item (the closing list is closed) so that the button is clicked. It always skips a button click and opens a drop-down list. Basically, I want the Button_Click event handler to be configured to fire after it is clicked. Here is my sample combo box that shows a button but is not clickable when it is in the selected item:

<ComboBox x:Name="MyCombo" Width="200" Height="30" ItemsSource="{Binding ListCombo}">
        <ComboBox.Resources>
            <DataTemplate DataType="{x:Type local:ComboItemClass}">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Path=SampleText}" Width="120" />
                    <Button Width="20" Content="..." Click="Button_Click"/>
                </StackPanel>
            </DataTemplate>
        </ComboBox.Resources>
    </ComboBox>
+3
source share
1 answer

comboboxes - , WPF, ( ) , , .

combobox . comobox , . , , .

EDIT:

, , .

    <ListBox>
        <ListBoxItem>
            <StackPanel Height="34" HorizontalAlignment="Left" Margin="12,16,0,0"  VerticalAlignment="Top" Width="430" Orientation="Horizontal">
                <Button Content="Edit"  />
                <Button Content="Delete"  />
                <TextBlock Text="Port Information here" VerticalAlignment="Center" Margin="20,0" />
            </StackPanel>

        </ListBoxItem>
        <ListBoxItem>
            <StackPanel Height="34" HorizontalAlignment="Left" Margin="12,16,0,0"  VerticalAlignment="Top" Width="430" Orientation="Horizontal">
                <Button Content="Edit"  />
                <Button Content="Delete"  />
                <TextBlock Text="Port Information here" VerticalAlignment="Center" Margin="20,0" />
            </StackPanel>

        </ListBoxItem>
        <ListBoxItem>
            <StackPanel  Height="34" HorizontalAlignment="Left" Margin="12,16,0,0"  VerticalAlignment="Top" Width="430" Orientation="Horizontal">
                <Button Content="Edit"  />
                <Button Content="Delete"  />
                <TextBlock Text="Port Information here" VerticalAlignment="Center" Margin="20,0" />
            </StackPanel>

        </ListBoxItem>
+2

Source: https://habr.com/ru/post/1743417/


All Articles