locked
Error opening another screen RRS feed

  • Question

  • Hi, I've been struggling with this for awhile.  I have a custom user control with a bar chart.  When the user clicks on a bar, I want to open a screen listing the data the bar represents, a drill-down chart.  I am close, I can bring up a message box, but if I change the code to open a screen, I receive the error:  "Operation is not valid due to the current state of the object."

    Here is the code where I get the error:

    using System;
    using System.Linq;
    using System.IO;
    using System.IO.IsolatedStorage;
    using System.Collections.Generic;
    using Microsoft.LightSwitch;
    using Microsoft.LightSwitch.Framework.Client;
    using Microsoft.LightSwitch.Presentation;
    using Microsoft.LightSwitch.Presentation.Extensions;
    
    namespace LightSwitchApplication
    {
        public partial class FileActivityByQuarter : ITracker
        {
            public void FilesActive_Execute(string quarterName)
            {
                this.ShowMessageBox("Active clicked:  " + quarterName);
            }
    
            public void FilesOpened_Execute(string quarterName)
            {
                this.Application.ShowFilesOpenedByQuarter(quarterName);
            }
    
            public void FilesClosed_Execute(string quarterName)
            {
                this.ShowMessageBox("Closed clicked:  " + quarterName);
            }
    
    
            void ITracker.FilesActive(string quarterName)
            {
                FilesActive_Execute(quarterName);
            }
    
            void ITracker.FilesClosed(string quarterName)
            {
                FilesClosed_Execute(quarterName);
            }
    
            void ITracker.FilesOpened(string quarterName)
            {
                FilesOpened_Execute(quarterName);
            }
        }
    }
    What am I missing?

    Monday, March 18, 2013 12:52 AM

Answers

  • Hi

    I think the error is because of the current application dispatcher. Use have to call lightswitch object from the logic thread. Use the below code:

    Application.Current.Details.Dispatcher.BeginInvoke(() =>
                        {
                            Application.Current.ShowFilesOpenedByQuarter(quartername);
                        });

    Regards

    Rashmi Ranjan Panigrahi
    www.lightswitchspecial.com

    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”.
    This will help other users to find their answer quickly.

    • Marked as answer by JohnMagruder Monday, March 18, 2013 4:23 AM
    Monday, March 18, 2013 2:54 AM

All replies

  • Hi

    I think the error is because of the current application dispatcher. Use have to call lightswitch object from the logic thread. Use the below code:

    Application.Current.Details.Dispatcher.BeginInvoke(() =>
                        {
                            Application.Current.ShowFilesOpenedByQuarter(quartername);
                        });

    Regards

    Rashmi Ranjan Panigrahi
    www.lightswitchspecial.com

    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”.
    This will help other users to find their answer quickly.

    • Marked as answer by JohnMagruder Monday, March 18, 2013 4:23 AM
    Monday, March 18, 2013 2:54 AM
  • Thanks, Rashmi, that worked perfectly!
    Monday, March 18, 2013 4:24 AM
  • Hi John

    You are most welcome.

    Regards


    Rashmi Ranjan Panigrahi
    www.lightswitchspecial.com

    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”.
    This will help other users to find their answer quickly.

    Monday, March 18, 2013 4:28 AM