In Development
Last Updated: 15 Jan 2024 14:51 by ADMIN
Christoph
Created on: 05 Sep 2023 08:17
Category: UI for .NET MAUI
Type: Bug Report
0
ComboBox: [Android] Initially selected item is not displayed when using background brush as implicit style

I tested Android and iOS only. Other platforms i cannot test at the moment.

 

Given the following implementation of the Combobox i observ different behaviour if the bound item is a enum or a class.

<telerik:RadComboBox x:Name="a"
                     ItemsSource="{Binding CloudProviders}"
                     SelectedItem="{Binding SelectedCloudProvider}"
                     IsClearButtonVisible="False">
    <telerik:RadComboBox.ItemTemplate>
        <DataTemplate>
            <Grid HeightRequest="40"
                  Padding="10">
                <Label Text="{Binding Title}"
                       TextColor="{DynamicResource DisabledTextColor}"
                       FontSize="14" />
            </Grid>
        </DataTemplate>
    </telerik:RadComboBox.ItemTemplate>
    <telerik:RadComboBox.SelectedItemTemplate>
        <DataTemplate>
            <Grid HeightRequest="40"
                  Padding="10">
                <Label Text="{Binding Title}"
                       TextColor="{DynamicResource DisabledTextColor}"
                       FontSize="14" />
            </Grid>
        </DataTemplate>
    </telerik:RadComboBox.SelectedItemTemplate>
</telerik:RadComboBox>

 

If the Itemssource is a Array of a enum type it works as intended.

If the Itemssource is a Array of classes the initial selected display member is not visible. The moment i tap into the closed combobox, the selected member is visible.

 

The attached screenshots show the page after loading and after touching into the white area(combobox) once.

 

For Localization and more details, we want to use classes. Is this a bug or do we have a issue in our code here?

 

4 comments
ADMIN
Didi
Posted on: 07 Sep 2023 04:43

Hello Christoph,

As I am not familiar with the exact setup you have, send me a sample project where I can research the behavior further. Based on our examples with complex object data binding, the ComboBox displays all items in the dropdown and when item is selected it is displayed in the control's input. So we cannot reproduce the issue you have described.

Regards,
Didi
Progress Telerik

A brand new .NET MAUI course was just added to the Virtual Classroom. The training course is developed to help you get started with the Telerik UI for .NET MAUI components and features. It aims to put you in the shoes of an engineer who adds new features to an existing application. You can check it out at https://learn.telerik.com
Christoph
Posted on: 07 Sep 2023 04:03

The DisplayMemberPath was set in some tests by me, sorry for mising out including that information. This didnt make any difference. If no DisplayMemberPath object.ToString() seems to be invoked to display.

What should be proof in this being an error, is screenshot-1.png (initial post), where you can see, that not even the dropdown icon is rendered.

 

ADMIN
Didi
Posted on: 06 Sep 2023 06:48

Hi Christoph,

I have reviewed the XAML and noticed you haven't set the DisplayMemberPath property. This is described here: https://docs.telerik.com/devtools/maui/controls/combobox/getting-started#binding-to-a-complex-object 

<telerik:RadComboBox ItemsSource="{Binding Items}" 
                DisplayMemberPath="Name"
                Placeholder="Select City"
                AutomationId="comboBox">
    <telerik:RadComboBox.ItemTemplate>
        <DataTemplate>
            <telerik:RadBorder BackgroundColor="LightYellow"
                        MinimumWidthRequest="300">
                <Label Text="{Binding Name}" 
                Padding="8, 7, 0, 7"
                TextColor="Black"/>
            </telerik:RadBorder>
        </DataTemplate>
    </telerik:RadComboBox.ItemTemplate>
    <telerik:RadComboBox.SelectedItemTemplate>
        <DataTemplate>
            <telerik:RadBorder BackgroundColor="LightBlue"
                        MinimumWidthRequest="300">
                <VerticalStackLayout>
                    <Label Text="{Binding Name}"
                    Padding="8, 7, 0, 7"
                    TextColor="Black"/>
                    <Label Text="{Binding Population}" 
                    FontSize="12"
                    Padding="8, 7, 0, 7"/>
                </VerticalStackLayout>
            </telerik:RadBorder>
        </DataTemplate>
    </telerik:RadComboBox.SelectedItemTemplate>
</telerik:RadComboBox>

Please review the documentation and the examples we have provided. If you have any further questions, open a support ticket.

I have changed the bug report status to Declined as this is not an issue in the control.

Regards,
Didi
Progress Telerik

A brand new .NET MAUI course was just added to the Virtual Classroom. The training course is developed to help you get started with the Telerik UI for .NET MAUI components and features. It aims to put you in the shoes of an engineer who adds new features to an existing application. You can check it out at https://learn.telerik.com
Christoph
Posted on: 06 Sep 2023 05:33
maybe the attached error message has something to do with it?
Attached Files: