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

RadListBox: SelectionChanged not fired

5 Answers 417 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 20 Jun 2013, 08:40 AM
Hi,

with the Q2 2013 update the SelectionChanged event of RadListBox does not fire anymore if an item is selected via code and the RadListBox is currently not visible. Is this new behaviour intended? I've switched back to the previous version.

Regards,
Michael

5 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 25 Jun 2013, 07:40 AM
Hello Michael,

We have tried to reproduce the issue, but with no luck. I have attached my test project and it would be great if you can check it out and let me know if I am not missing something. If it needs something additional it would help if you can add it and send it back to us.
Also if you can think of something else that could be prevent us from reproducing the issue, don't hesitate to write it down.
Please note that I have tested it with the 2013.2.611 and 2013.1.403 versions of the controls.

Regards,
Georgi
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Michael
Top achievements
Rank 1
answered on 25 Jun 2013, 09:23 AM
Hello Georgi,

you can reproduce the issue when changing your xaml to this:

 

    <Grid>
    <StackPanel>
        <telerik:RadDropDownButton Content="test">
            <telerik:RadDropDownButton.DropDownContent>
                <telerik:RadListBox x:Name="listBox" SelectionChanged="listBox_SelectionChanged">
                    <telerik:RadListBoxItem Content="Item 1"/>
                    <telerik:RadListBoxItem Content="Item 2"/>
                    <telerik:RadListBoxItem Content="Item 3"/>
                    <telerik:RadListBoxItem Content="Item 4"/>
                </telerik:RadListBox>
            </telerik:RadDropDownButton.DropDownContent>  
        </telerik:RadDropDownButton>

        <telerik:RadButton Click="RadButton_Click" Content="SelectItem"/>
        <TextBlock x:Name="log"/>
    </StackPanel>
</Grid>

0
Georgi
Telerik team
answered on 27 Jun 2013, 08:25 AM
Hi Michael,

Pointing that the event is not fired if the ListBox is not visible helped a lot.
So the change we have made is that the SelectionChanged will be thrown when the all parts of the ListBox are loaded in the visual tree. Also the change was intentional as we thought that there is no need the SelectionChange to be thrown on a different stage than when the control is visible.
So it would be great if you can give us more information about your scenario (simple project would help a lot) and why firing the selection change when opening the DropDown does not work for you.
So when we know your point of view we would be able to determine whether to get back to the old behavior or take some other actions.

Regards,
Georgi
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Michael
Top achievements
Rank 1
answered on 28 Jun 2013, 10:47 AM
Hi Georgi,

my application uses a DropDownButton to give the user the opportunity to select an option. The selected option will be stored in the application's settings and restored upon restarting the application. Restoring the last selected option now doesn't work anymore.

Here's a sample:
xaml:
<Window x:Class="ListBoxSelectionChanged.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                Title="MainWindow" Height="350" Width="525">
   <Grid>
        <StackPanel>
            <telerik:RadDropDownButton Name="button" Content="Options"  Margin="5">
                <telerik:RadDropDownButton.DropDownContent>
                    <telerik:RadListBox x:Name="listBox" SelectionChanged="listBox_SelectionChanged">
                        <telerik:RadListBoxItem Content="Option 1"/>
                        <telerik:RadListBoxItem Content="Option 2"/>
                        <telerik:RadListBoxItem Content="Option 3"/>
                        <telerik:RadListBoxItem Content="Option 4"/>
                    </telerik:RadListBox>
                </telerik:RadDropDownButton.DropDownContent>                 
            </telerik:RadDropDownButton>
             
            <TextBlock x:Name="workarea" Margin="5" FontSize="20"/>
        </StackPanel>
    </Grid>
</Window>

cs:

using System;
using System.Windows;
using System.Windows.Controls;
 
namespace ListBoxSelectionChanged
{
   /// <summary>
   /// Interaction logic for MainWindow.xaml
   /// </summary>
   public partial class MainWindow : Window
   {
      public MainWindow()
      {
         InitializeComponent();
 
         // Restoring last option selected by user
         listBox.SelectedIndex = Properties.Settings.Default.LastOption;
      }
 
 
      private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
      {
         workarea.Text = listBox.SelectedItem.ToString();
 
         // saving option selected by user
         Properties.Settings.Default.LastOption = listBox.SelectedIndex;
         Properties.Settings.Default.Save();
 
         button.IsOpen = false;
      }
   }
}


I agree that in most cases firing an event from a non-visible control is somewhat useless. Maybe you could consider to give the ListBox an additional option so we can configure its behaviour.

Regards,
Michael


0
Georgi
Telerik team
answered on 03 Jul 2013, 11:00 AM
Hi Michael,

Thank you for the feedback.
We have considered your scenario and we think that it is a valid scenario and we should be providing our clients that functionality.
So we have logged it here in our Public Issue Tracking System, where you can track its progress.
Please, excuse us for the inconvenience. We have added points to your account for the report. Don't hesitate to contact us if you have other questions.

Regards,
Georgi
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ListBox
Asked by
Michael
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Michael
Top achievements
Rank 1
Share this question
or