This is a migrated thread and some comments may be shown as answers.

Selecting an item works only once

6 Answers 250 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Uwe Zimmermann
Top achievements
Rank 1
Uwe Zimmermann asked on 25 Nov 2010, 08:03 AM
Hallo,

i have a problem with a RadComboBox. It's ItemsSource is an ObservableCollection<ThemeInfo>. The RadComboBox is a part of a RadRibbonBar. I bound my RibbonBarViewModel to the RadRibbonBar's DataContext property.

Here is the xaml code for my RadComboBox:

<telerik:RadComboBox
                            Name="themesRadComboBox"
                            Width="100" 
                            ItemsSource="{Binding ThemeInfos}"
                            SelectedItem="{Binding SelectedThemeInfo, Mode=TwoWay}"
                            Command="{Binding ChangeApplicationThemeCommand}"
                            DisplayMemberPath="DisplayName">
                        </telerik:RadComboBox>

If i select an item it works fine, but if i do this the second time, DropDownList of RadComboBox stays closed. If the RadComboBox has focus and i use the arrow keys it also works as expected. Any ideas to solve this?

6 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 30 Nov 2010, 04:45 PM
Hi Uwe,

Thank you for contacting us.

Could you please specify what version of our RadControls you use? Could you please try out latest Q3 binaries and let me know if issue is resolved.
I tried to reproduce the problem, but to no avail. Could you please let me know if you can reproduce the problem with our online examples - http://demos.telerik.com/wpf/?ComboBox/FirstLook.

Best wishes,
George
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Uwe Zimmermann
Top achievements
Rank 1
answered on 01 Dec 2010, 07:01 AM
Thanks for your answer, i tried out the latest binaries, but it's still the same. I think, the problem is my command binding. If i remove the declaration of the command binding from xaml, i can select like expected (but now without code execution at selection changed event). I'm new to WPF and MVVM and i would like to get an example how i can bind a command to a RadComboBox in my view model which will be executed if selection changed event fires. Thanks.
0
George
Telerik team
answered on 06 Dec 2010, 09:39 AM
Hello,

Attached you can find the sample using RadComboBox with MVVM pattern. I hope this helps.

Please do not hesitate to contact us if you require any further information.


All the best,
George
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Odd Veibust
Top achievements
Rank 1
answered on 11 Oct 2011, 02:04 PM
Hi.

I see this is an old subject, but I am having the same problem now.

When I bind the RadComboBox to an observablecollection, I can only select once. When I try to select another item, nothing happens. The ClearSelectionButton works, and after clearing I can select another item.
<telerik:RadComboBox Grid.Column="0" Grid.Row="3" 
    Grid.ColumnSpan="2" x:Name="GearComboBox" 
    Margin="5,0,0,0" ClearSelectionButtonVisibility="Visible" 
    ClearSelectionButtonContent="Clear Selection" 
    ItemsSource="{Binding Source={StaticResource RegistersModelView}, Path=FishingGears}" 
    DisplayMemberPath="Code" />

If I bind SelectedItem, it shows the right selecteditem, but I can not select another item. Here, the ClearSelectionButton is working, and I can after clicking it select a new item.
<telerik:RadComboBox Grid.Column="0" Grid.Row="3"
    Grid.ColumnSpan="2" x:Name="GearComboBox"
    Margin="5,0,0,0" ClearSelectionButtonVisibility="Visible"
    ClearSelectionButtonContent="Clear Selection"
    ItemsSource="{Binding Source={StaticResource RegistersModelView}, Path=FishingGears}"
    SelectedItem="{Binding Path=RegistrationInformation.FishingGear, Mode=TwoWay}"
    DisplayMemberPath="Code" />

I have both tried with DisplayMemberPath and an ItemTemplate, both have the same behaviour.

If I add some RadComboBoxItems manually, instead of binding to a DataSource, everything works like a charm.
<telerik:RadComboBox Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" x:Name="GearComboBox2" Margin="5,0,0,0" ClearSelectionButtonVisibility="Visible" ClearSelectionButtonContent="Clear Selection">
    <telerik:RadComboBox.Items>
        <telerik:RadComboBoxItem>
            <telerik:RadComboBoxItem.Content>
                <TextBlock Text="Item 1" />
            </telerik:RadComboBoxItem.Content>
        </telerik:RadComboBoxItem>
        <telerik:RadComboBoxItem>
            <telerik:RadComboBoxItem.Content>
                <TextBlock Text="Item 2" />
            </telerik:RadComboBoxItem.Content>
        </telerik:RadComboBoxItem>
    </telerik:RadComboBox.Items>
</telerik:RadComboBox>

I'm using the latest binaries (downloaded today).

Do you have any suggestions on what is causing the problem? Anything I need to be aware of in the ModelView? I see in your last post that you refer to an attached example, but it seems like the attachment is gone.

0
Odd Veibust
Top achievements
Rank 1
answered on 12 Oct 2011, 09:39 AM
I now tried using a "normal" ComboBox, same problem there, so atleast it's not a problem with the RadComboBox. If you got any ideas, it would be helpful though.
0
Odd Veibust
Top achievements
Rank 1
answered on 12 Oct 2011, 02:17 PM
Nevermind. Someone had overridden the Equals method in the base class of the objects. It was never equal :/
Tags
ComboBox
Asked by
Uwe Zimmermann
Top achievements
Rank 1
Answers by
George
Telerik team
Uwe Zimmermann
Top achievements
Rank 1
Odd Veibust
Top achievements
Rank 1
Share this question
or