RadListBox Losing selected items on month change

3 posts, 1 answers
  1. Tim
    Tim avatar
    41 posts
    Member since:
    Oct 2012

    Posted 14 Dec 2012 Link to this post


    I have a RadListBox that gets populated from the value in a RadComboBox. The RadListBox is below:
    <telerik:RadListBox Name="myList" Width="200" Height="200" ItemsSource="{Binding ResourceItemList}" >
      <telerik:RadListBox.ItemTemplate>
        <DataTemplate x:Name="myTemplate">
          <StackPanel Orientation="Horizontal">
            <CheckBox ClickMode="Press" IsChecked="{Binding IsSelected, Mode=TwoWay}" telerik:StyleManager.Theme="Office_Silver">
              <CheckBox.Content>
                <TextBlock Text="{Binding Name}"></TextBlock>
              </CheckBox.Content>
            </CheckBox>
          </StackPanel>
        </DataTemplate>
      </telerik:RadListBox.ItemTemplate>
    </telerik:RadListBox>

    Whenever I click to the next or previous month, the selected items in the RadListBox are unchecked. This is because of the MainPageViewModel code below. The RadListBox is populated from this.workerGetServiceAppointments.DoWork shown below:

    public MainPageViewModel(ILifestyleLiftServiceAgent serviceAgent)
           {
               this.ResourceItemList = new ObservableCollection<ResourceItem>();
               
               if (!IsDesignTime)
               {
                   if (serviceAgent != null) ServiceAgent = serviceAgent;
                   SetNonWorkingHours();
                   this.workerGetServiceAppointments.DoWork += new DoWorkEventHandler(workerGetServiceAppointments_DoWork);
                   this.workerGetServiceAppointments.RunWorkerCompleted += new RunWorkerCompletedEventHandler(workerGetServiceAppointments_RunWorkerCompleted);
                   ServiceAgent.GetSites(Centers);
               }
           }

    And here's the DoWork code:

    void workerGetServiceAppointments_DoWork(object sender, DoWorkEventArgs e)
            {
                    ServiceAgent.GetResources(SelectedSiteId, ResourceItemList, UpdateResourceTypes);
            }


    The GetResources call works and the RadListBox is re-populated. How can I keep the selected items in the ResourceItemList from resetting when I change the month or view from Day/Week/Month and only change it when the RadComboBox is modified?

    Tim

  2. Answer
    Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 19 Dec 2012 Link to this post

    Hi Tim,

    We tried to reproduce the issue but with no success.

    Could you try to recreate the issue in a sample project and send it to us so we can observe the issue at our side and see what could be the cause of it?

    Kind regards,
    Vladi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Tim
    Tim avatar
    41 posts
    Member since:
    Oct 2012

    Posted 19 Dec 2012 Link to this post

    The issue was in the code. The RadListBox was rebuilding everytime regardless if the RadComboBox was changed.

    It is now working.

    Tim
Back to Top