Hi,
When my ListBox is loaded for the first time, I want it to already have the SelectedItem highlighted, as if it is already clicked. How can I achieve that?
I use the MVVM Light toolkit, and I have a TwoWay binding on the SelectedItem to a property in my ViewModel.
I know that the SelectedNetwork property is set correctly when the ViewModel is initialized, but the ListBox does not highlight the selected item.
Regards,
Roar Bjørndal-Rasmussen
When my ListBox is loaded for the first time, I want it to already have the SelectedItem highlighted, as if it is already clicked. How can I achieve that?
I use the MVVM Light toolkit, and I have a TwoWay binding on the SelectedItem to a property in my ViewModel.
<
telerik:RadListBox
ItemsSource
=
"{Binding AllNetworks}"
SelectedItem
=
"{Binding SelectedNetwork, Mode=TwoWay}"
>
...
...
...
</
telerik:RadListBox
>
I know that the SelectedNetwork property is set correctly when the ViewModel is initialized, but the ListBox does not highlight the selected item.
Regards,
Roar Bjørndal-Rasmussen
4 Answers, 1 is accepted
0
Accepted
Hello,
George
the Telerik team
Please, double check whether the selected network equals one of the networks in the RadListBox.ItemsSource collection. I prepared a sample project that covers the given scenario and everything works fine. Please, refer to the attachment and let me know if I missed something.
George
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
0
Roar
Top achievements
Rank 1
answered on 17 Sep 2012, 06:15 AM
Hi,
Thanks, the solution was as you pointed out to find the selected network in my ItemsSource collection, and to assign that to the SelectedItem. It now works like a charm. :-)
Regards,
Roar Bjørndal-Rasmussen
Thanks, the solution was as you pointed out to find the selected network in my ItemsSource collection, and to assign that to the SelectedItem. It now works like a charm. :-)
Regards,
Roar Bjørndal-Rasmussen
0
jackson
Top achievements
Rank 1
answered on 06 Apr 2016, 07:29 PM
The example works if one item is selected. How to make it work for multiple items? I tried to change selectedCountry to List<Country> and ObservableCollection<Country>, neither worked.
Please help. Thanks!
0
Hi Jackson,
In order to achieve the desired the SelectedItemsSource attached property needs to be set with the collection of items you need to select. Please, check the following article from our help documentation that provides detailed information how to achieve the desired:
http://docs.telerik.com/devtools/wpf/controls/radlistbox/features/selecteditemssource
We have also modified the sample project with the described in the article approach.
Hope this helps.
Regards,
Nasko
Telerik
In order to achieve the desired the SelectedItemsSource attached property needs to be set with the collection of items you need to select. Please, check the following article from our help documentation that provides detailed information how to achieve the desired:
http://docs.telerik.com/devtools/wpf/controls/radlistbox/features/selecteditemssource
We have also modified the sample project with the described in the article approach.
Hope this helps.
Regards,
Nasko
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.