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

ComboBox PlaceholderText & ComboBoxAssist.Label is visually confused #269

Open
qfmee opened this issue Jul 30, 2023 · 11 comments
Open

ComboBox PlaceholderText & ComboBoxAssist.Label is visually confused #269

qfmee opened this issue Jul 30, 2023 · 11 comments
Labels
bug Something isn't working

Comments

@qfmee
Copy link

qfmee commented Jul 30, 2023

1:ComboBox PlaceholderText & ComboBoxAssist.Label is visually confused with the selected content.
2:When the list opened, click on another location on the interface the list does not close. But Filled and Outline styles can be close。
3:I really hope this control can be migrated to Material. Styles/Resources/Themes/

@SKProCH SKProCH added the bug Something isn't working label Jul 31, 2023
@Metritutus
Copy link

Metritutus commented Sep 1, 2023

DisplayMemberBinding also appears to behave oddly. It seems to be getting treated as a label for the control, and floats to the top-left of the control as a result. In addition, because of this behaviour, if using ComboBoxAssist.Label as well then the two values overlap. This is on 3.0.0-avalonia11-preview6.19-nightly.

@seikosantana
Copy link

Is the part where selected item gets displayed in placeholder's place?

@SKProCH
Copy link
Collaborator

SKProCH commented Sep 26, 2023

Is the part where selected item gets displayed in placeholder's place?

What do you mean?

@seikosantana
Copy link

Here's ComboBox with two items
image

When ComboBox items are created using binding

<ComboBox PlaceholderText="Lines" ItemsSource="{Binding AvailableLines}"
          SelectedItem="{Binding SelectedLine, Mode=TwoWay}">
    <ComboBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding StringFormat='Line {0}'}"></TextBlock>
        </DataTemplate>
    </ComboBox.ItemTemplate>
</ComboBox>

Selecting an item places the selected item label on the place of the placeholder
image

While the one created like in the Demo

<ComboBox PlaceholderText="Lines">
    <TextBlock>Line 1</TextBlock>
    <TextBlock>Line 2</TextBlock>
</ComboBox>

is put in the correct place
image

Comparison of ComboBoxes with selected item of first and second:
image

Is this related to this issue?

@SKProCH
Copy link
Collaborator

SKProCH commented Sep 27, 2023

Yep, I think this is related.

@seikosantana
Copy link

So is there a way to put the selected item display in it's intended place? Or any workarounds?

@SKProCH
Copy link
Collaborator

SKProCH commented Sep 27, 2023

So is there a way to put the selected item display in it's intended place? Or any workarounds?

I'll try to take a look.

@seikosantana
Copy link

Thanks, I appreciate it. The application I am working on is getting close to release deadline, and I'm still new to Avalonia and XAML. Wish could do something about these..

@SKProCH
Copy link
Collaborator

SKProCH commented Sep 27, 2023

Seems like this is completely overrides an template. As for workaround, you can use:

<ComboBox PlaceholderText="Lines" ItemsSource="{Binding AvailableLines}"
          SelectedItem="{Binding SelectedLine, Mode=TwoWay}">
    <ComboBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding StringFormat='Line {0}'}" VerticalAlignment="Center"></TextBlock>
        </DataTemplate>
    </ComboBox.ItemTemplate>
</ComboBox>

@seikosantana
Copy link

Thanks a lot, that works

@Andy-DG
Copy link

Andy-DG commented Oct 29, 2023

<ComboBox Grid.Row="1" Margin="0,0,0,10" ItemsSource="{Binding HotkeyOptions}" SelectedItem="{Binding Scene.Hotkey}" ToolTip.Tip="Select a hotkey"> <ComboBox.ItemTemplate> <DataTemplate> <TextBox Height="20" Watermark="Select hotkey" Text="{Binding}" VerticalAlignment="Center" HorizontalAlignment="Left"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox>

I used this, this replaces the PlaceHolderText by a watermark, giving it a cleaner position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants