Declined
Last Updated: 22 Oct 2024 06:59 by ADMIN
Jones
Created on: 15 Oct 2024 20:00
Category: UI for .NET MAUI
Type: Bug Report
0
SegmentedControl issue about displaying the selected item in some specific situations

In most situations, the Segmented control is working as expected but it seems that it uses an optimization that is making it not to show the currently selected item in the UI.

In my page I have a list of items that are shown or hidden according to what the user selects.

Each item has a template and there is a template using the Segmented control.

If in the 1st item of the list I select the first tab in the segmented control, refresh the list, and select the 2nd tab of the first item in the new list,

everything work fine, I can switch between the lists and everything is ok.

But if I select the same tab, after I switch the content of the list, even having SelectedIndex, SelectedItem and ItemSource correct, it doesn't display the selected tab.

I tried a lot, calling OnPropertyChanged in many places, using SelectedItem, SelectedIndex, both.

No way for it to work.

It seems like an optimization that doesn't redraw the selected item by mistake if it is equal in value to the previous one.

For you to better understand our case, the page is a row of a table, where the user scroll through rows of this table.
If in the 1st row he selects the 1st tab and in the 2nd row too, if he tries to move back to row 1, the displayed tab is not shown.

Thanks in advance,

Jones Abramoff

7 comments
Jones
Posted on: 22 Oct 2024 06:56

Hi,

We were using a custom listview and the segmented button worked ok with the regular listview.

No need to further investigate.

Thanks a lot.

ADMIN
Yana
Posted on: 21 Oct 2024 20:59

Hello Jones,

I am not sure whether this is something related to the Segmented or to the ListView CachingStrategy as I am still not able to to reproduce the erroneous behavior - I've tested placing the Segmented inside the ListView template and showing/hiding it, still, the selected index is preserved.

I'd ask you to send me the ListView definition and the logic for hiding the items, so I can check the exact use case.

Regards,
Yana
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Jones
Posted on: 20 Oct 2024 12:47

Hi, if the segmented button is inside a listview with ListViewCachingStrategy RetainElement it works as expected but if it's RecycleElement, it fails as described previously.

Is ist a limitation specific for the Segmented control?

Best regards,

Jones

 
ADMIN
Yana
Posted on: 18 Oct 2024 09:56

Hi Jones,

Thank you for sending the Segmented definition. I have an additional question - what's that list of items control? Can you send me the complete XAML?

Thank you in advance.

Regards,
Yana
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Jones
Posted on: 17 Oct 2024 17:47
This is the xaml segment:
                <Grid
                      FlowDirection="{Binding Source={x:Static sty:Config.IsRTL},Converter={StaticResource IsRtl2FlowDirectionRtl}}">
                    <telerik:RadSegmentedControl x:Name="segment"
                                                 ItemsSource="{Binding Path=ComboboxItems}"
                                                 SelectedIndex="{Binding Path=SelectedIndex,Mode=TwoWay}"
                                                 HorizontalOptions="FillAndExpand"
                                                 SelectedSegmentTextColor="#666666"
                                                 DisabledSegmentTextColor="#CCCCCC">
                        <telerik:RadSegmentedControl.Resources Stroke="{Binding Source={x:Static sty:StyleKit+Colors.OcButtonColor}}" />
                    </telerik:RadSegmentedControl>
                </Grid>

In the code behind:
        private int _selectedIndex;
        public int SelectedIndex
        {
            get
            {
                return _selectedIndex;
            }
            set
            {
                if (_selectedIndex != value)
                {
                    _selectedIndex = value;
                    OnPropertyChanged(nameof(SelectedIndex));
                    if (_selectedIndex != -1 && Type == FormFieldType.RadioButtons && SubTypeAsEnum == FormFieldSubType.RadioButtonsSubType_SegmentedControl && ComboboxItems != null && ComboboxItems.Count > _selectedIndex)
                    {
                        //.... do something not related to the selected index
                    }
                }
            }
        }
And while loading the page:
                                        ffts._selectedIndex = index;
                                        OnPropertyChanged(nameof(ffts.SelectedIndex));

ADMIN
Yana
Posted on: 17 Oct 2024 12:24

Hi Jones,

Would it be possible for you to send us some code showing exactly the use case? I've tried to follow the provided instructions, still, there are some missing pieces and I would prefer testing the exact scenario you have instead of make guess of the used layout and controls.

I look forward to your reply.

Regards,
Yana
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Jones
Posted on: 16 Oct 2024 07:32
"For your better understanding of our case, the page shows a row of a table, where the user can scroll through rows of this table.
If in the 1st row he selects the 1st tab and in the 2nd row too, if he tries to move back to row 1, the selected tab is not shown, as if SelectedIndex was -1."