2

I've been googling around for something similar to FullRowSelect for a listview. Currently my listbox items are only selectable if you click on a part of it that is being taken up with content eg a textblock, item etc. This means that the "clickable" area is dependant on how long the entry is, but ideally i'd like to be able to click anywhere within the rectangle that defines each item.

I hope that makes sense

user627388
  • 21
  • 2

1 Answers1

1

You need to adjust the ItemContainerStyle within the ListBox so that its HorizontalContentAlignment is set as Stretch versus Left. You can still align the content within the ListBoxItem as needed.

    <Window.Resources>
        <Style x:Key="Stretched" TargetType="{x:Type ListBoxItem}">
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        </Style>
    </Window.Resources>

    <Grid>
        <ListBox ItemContainerStyle="{StaticResource Stretched}">
            <ListBox.Items>
                <ListBoxItem>
                    <Grid>
                        <TextBox HorizontalAlignment="Left" Height="25" Width="100"/>
                    </Grid>
                </ListBoxItem>
                <ListBoxItem>
                    <Grid>
                        <TextBox HorizontalAlignment="Left" Height="25" Width="100"/>
                    </Grid>
                </ListBoxItem>
            </ListBox.Items>
        </ListBox>
    </Grid>
Aaron McIver
  • 24,527
  • 5
  • 59
  • 88