AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.22k stars 2.18k forks source link

ComboBox HorizontalContentAlignment="Stretch" is not working #5718

Open shaosss opened 3 years ago

shaosss commented 3 years ago

Describe the bug When HorizontalContentAlignment="Stretch" is set it is rendered the same as with HorizontalContentAlignment="Center". Other values (Center, Left and Right) values works as expected.

To Reproduce Insert this control to the page:

        <ComboBox HorizontalAlignment="Stretch" Grid.Column="0" 
                  HorizontalContentAlignment="Stretch" SelectedIndex="0">
            <ComboBoxItem>
                <Grid RowDefinitions="100" ColumnDefinitions="100,*">
                    <Image Grid.Column="0" DockPanel.Dock="Left" Height="100" Width="100"></Image>
                    <StackPanel Grid.Column="1" Height="100">
                        <Label HorizontalAlignment="Stretch" Margin="4">Name</Label>
                        <ProgressBar HorizontalAlignment="Stretch" Margin="4"></ProgressBar>
                        <Label HorizontalAlignment="Stretch" Margin="4">Formats</Label>
                    </StackPanel>
                </Grid>
            </ComboBoxItem>
        </ComboBox>

Expected behavior A selected Item is shown stretched (same as items in dropdown).

Screenshots Here is the example: image

Desktop (please complete the following information):

maxkatz6 commented 3 years ago

It doesn't work with control items in combobox, because in this case Viewbox is used to display content. As a workaround Items with ItemTemplate should work.