RadMultiColumnComboBox - Initial SelectedItem does not show

1 Answer 113 Views
MultiColumnComboBox
Osman
Top achievements
Rank 1
Iron
Osman asked on 18 Jan 2024, 03:23 PM | edited on 18 Jan 2024, 03:33 PM

I have the following XAML code:

<telerik:RadMultiColumnComboBox 
    VerticalAlignment="Top" 
    Width="250" 
    DisplayMemberPath="Name" 
    IsReadOnly="True" 
    SelectionMode="Single" 
    SelectionBoxesVisibility="Hidden" 
    CloseDropDownAfterSelectionInput="True"                   
    DropDownWidth="320"
    SelectedItem="{Binding SelectedMandant}">
    <telerik:RadMultiColumnComboBox.ItemsSourceProvider>
        <telerik:GridViewItemsSourceProvider ItemsSource="{Binding MandantCollection}" AutoGenerateColumns="False" RowIndicatorVisibility="Hidden"> 
            <telerik:GridViewItemsSourceProvider.Columns>
                <telerik:GridViewDataColumn Header="Mandant" DataMemberBinding="{Binding Path=Name}"/>
                <telerik:GridViewDataColumn 
                    Header="Letzter Abschluss" 
                    DataMemberBinding="{Binding Path=FibuAbschluss}" 
                    DataFormatString="{} {0:dd.MM.yyyy}" 
                    TextAlignment="Center" 
                    HeaderTextAlignment="Center"/>
            </telerik:GridViewItemsSourceProvider.Columns>
        </telerik:GridViewItemsSourceProvider>
    </telerik:RadMultiColumnComboBox.ItemsSourceProvider>
    <telerik:EventToCommandBehavior.EventBindings>
        <telerik:EventBinding EventName="SelectionChanged" Command="{Binding SelectedMandantChangedCmd}" RaiseOnHandledEvents="True" PassEventArgsToCommand="True"/>
    </telerik:EventToCommandBehavior.EventBindings>
</telerik:RadMultiColumnComboBox>

Now everything works fine beside that the first time when the UI is rendered, the RadMultiColumnComboBox Input does not show the current selected item.

I set the SelectedItem in the constructor of my view model:



private Mandant? _selectedMandant;
public Mandant? SelectedMandant
{
    get => _selectedMandant;
    set
    {
        _selectedMandant = value;
        OnPropertyChanged();
    }
}

public KontoViewModel(CommonDbContext commonDbContext, StruebyWinBContext winBContext) { ...... if(MandantCollection.Count > 0) { SelectedMandant = MandantCollection[0]; ...... } ....... }

I see that the SelectedMandat has a value and also it works fine after i select another item, then the item shows.

But the first time after loading, the RadMultiColumnComboBox Input does not show any value, its empty.

It should show the selected item that i set in the constructor of my view model.

Can anyone help me here, thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Osman
Top achievements
Rank 1
Iron
answered on 18 Jan 2024, 04:05 PM | edited on 18 Jan 2024, 04:06 PM

Alright I found the solution:


<telerik:RadMultiColumnComboBox 
    VerticalAlignment="Top" 
    Width="250" 
    DisplayMemberPath="Name" 
    IsReadOnly="True" 
    SelectionMode="Single" 
    SelectionBoxesVisibility="Collapsed" 
    CloseDropDownAfterSelectionInput="True"                   
    DropDownWidth="320"
    SelectedItem="{Binding SelectedMandant}">
I had to use SelectionBoxesVisibility="Collapsed" instead of "Hidden"
Tags
MultiColumnComboBox
Asked by
Osman
Top achievements
Rank 1
Iron
Answers by
Osman
Top achievements
Rank 1
Iron
Share this question
or