Trying to clear a binded ObservableCollection hangs app

8 posts, 1 answers
  1. Magnus
    Magnus avatar
    5 posts
    Member since:
    Mar 2009

    Posted 08 Aug 2011 Link to this post

    Hi.

    I want to clear the collection that the Chart controls is bound to.
    Based on the ExamplesCS_WP samples solution, the LiveFeed.xaml page, I add a button and on the click event of that button I reset the data bound collection:
    private void btnReset_Click(object sender, RoutedEventArgs e)
    {
      Deployment.Current.Dispatcher.BeginInvoke(() =>
        {
          this.indexItemsSource.Clear();
        });
    }

    But this hangs the entire app. I can't even use the back button.
    Any ideas?

    Regards,
    Magnus
  2. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 08 Aug 2011 Link to this post

    Hi Magnus,

    Thanks for writing and for reporting this issue.

    Based on the information that you shared with us we cannot be sure what exactly causes the erroreous behavior. Could you please share with use some more XAML and C# code or possibly a sample project that we can use to reproduce the case so that we can better understand it and see how we can help.

    Please note that in order to be able to attach a sample project you will have to open a new support ticket.

    Thanks for your time.

    Regards,
    Deyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. DevCraft banner
  4. Magnus
    Magnus avatar
    5 posts
    Member since:
    Mar 2009

    Posted 08 Aug 2011 Link to this post

    Hi Deyan.
    Thanks for your reply.

    Sure, i can open a support ticket. But really, it's very simple to just grab the Telerik ExamplesCS_WP solution, modify the Chart\Features\LiveFeed.xaml  to add a button:

    In the Grid, add a row:
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="100"/>
        <RowDefinition Height="Auto"/> <!-- <====Add this  -->
    Add the button at the end of the grid:
          <Button x:Name="btnReset" Grid.Row="6" Content="Reset" Click="btnReset_Click"></Button>
        </Grid>
    </local:ExampleControlBase

    Add the code behind in LiveFeed.xaml.cs:
    private void btnReset_Click(object sender, RoutedEventArgs e)
       {
         Deployment.Current.Dispatcher.BeginInvoke(() =>
          {
            this.indexItemsSource.Clear();
          });
       }

    And to avoid an exception because of an empty source collection in the OnTimer, check for any items exists:
        private void OnTimer(object sender, EventArgs e)
        {
          if (indexItemsSource.Count > 0)
          {
            this.indexItemsSource.RemoveAt(0);
            this.volumeItemsSource.RemoveAt(0);
          }
    ...
    ...

    Run the Telerik Examples demo, navigate to "browse all controls"-> "Chart - Features" and click the reset button.

    Hope this helps.

    Regards,
    Magnus
  5. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 10 Aug 2011 Link to this post

    Hi Magnus,

    Thanks for writing back and for the details.

    I would like to inform you that I have been able to reproduce the issue. I will log it in our TODO system for fixing and we will provide a fix for it in our next major release.

    In case this issue is a show-stopper for you, let me know and we will make sure to deliver an Internal Build containing a fix as soon as possible.

    I have updated your Telerik points for bringing our attention to this issue.

    Thanks for your time.

    Regards,
    Deyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  6. Magnus
    Magnus avatar
    5 posts
    Member since:
    Mar 2009

    Posted 10 Aug 2011 Link to this post

    Ok, that sounds great.
    Yes, I'm very interested in an internal build, since I have actually submitted an app to the Market Place with similar functionality.
    Needless to say, I would really have a majore release/fix as soon as possible.

    I have also noted that binding a Chart to an empty ObservableCollection<> will pretty much create the same hang.
    (So I suppose that's the main culprit)

    Regards,
    Magnus
  7. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 11 Aug 2011 Link to this post

    Hello Magnus,

    Thanks for writing back.

    Since the developer responsible for the RadChart codebase is currently on vacation, we will be able to release an internal build in the next week.

    Do not hesitate to get back to us in case you have further questions or need assistance.

    All the best,
    Deyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  8. Answer
    Georgi
    Admin
    Georgi avatar
    296 posts

    Posted 18 Aug 2011 Link to this post

    Hi Magnus,

    I would also like to thank you for bringing our attention to this issue.

    I am excited to share that we have just released an update of our tools, which targets the new Mango version of WP7. In this release the issue is fixed and you should be able to safely clear the collection of business objects.

    More information about the release may be found in this blog post.

    Kind regards,
    Georgi
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  9. Magnus
    Magnus avatar
    5 posts
    Member since:
    Mar 2009

    Posted 25 Aug 2011 Link to this post

    Hi Georgi.

    Yes, this new release fixed this problem.
    Thanks.

    Regards,
    Magnus
Back to Top
DevCraft banner