Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListBox.ItemTemplate doesn't stretch entire background #666

Open
J0nathan550 opened this issue Mar 16, 2024 · 0 comments
Open

ListBox.ItemTemplate doesn't stretch entire background #666

J0nathan550 opened this issue Mar 16, 2024 · 0 comments

Comments

@J0nathan550
Copy link

I noticed when I was preparing my ListBox item template. I wanted to make entire ListBoxItem background to be ImageSourceBrush. But unfortunately by default the ListBox Item doesn't stretch the whole width and height.

Overriding the ItemContainerStyle will break the modern style of ListBox.

Any ideas how to stretch the grid to an entire ListBoxItem?

Code:

        <ListBox ItemsSource="{Binding SongsList}" SelectedItem="{Binding CurrentSong}" Background="Black" Margin="0,5,0,0">
            <ListBox.ItemTemplate>
                <DataTemplate DataType="models:SongModel">
                    <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Tag="{Binding SongLink}">
                        <Grid.Background>
                            <ImageBrush Stretch="UniformToFill" ImageSource="{Binding Icon}" Opacity="0.5" RenderOptions.BitmapScalingMode="Fant"/>
                        </Grid.Background>
                        <TextBlock Text="{Binding Title}" TextTrimming="CharacterEllipsis"/>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant