RadListBox: SelectionChanged not fired

6 posts, 0 answers
  1. Michael
    Michael avatar
    34 posts
    Member since:
    Oct 2009

    Posted 20 Jun 2013 Link to this post

    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
  2. Georgi
    Admin
    Georgi avatar
    349 posts

    Posted 25 Jun 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Michael
    Michael avatar
    34 posts
    Member since:
    Oct 2009

    Posted 25 Jun 2013 Link to this post

    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>

  5. Georgi
    Admin
    Georgi avatar
    349 posts

    Posted 27 Jun 2013 Link to this post

    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 >>
  6. Michael
    Michael avatar
    34 posts
    Member since:
    Oct 2009

    Posted 28 Jun 2013 Link to this post

    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


  7. Georgi
    Admin
    Georgi avatar
    349 posts

    Posted 03 Jul 2013 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready