Programatically close current window and open new window

hi,
I am in a click event of a button and want to close the current window and open a new window if a condition is met.
else if(MyText.Content=="OpenNew")
newwindow sw = new newwindow();
sw.Dispatcher.Invoke(new Action(() => sw.Show()));
this.Dispatcher.Invoke(new Action(() => this.Close()));
But I always get the System.InvalidOperationException.
Pls help me with this.
Thanks,
Shaleen
TheHexLord

If you are trying to create the window on a new thread, you must set the  ApartmentState of the window to STA as described here:
http://reedcopsey.com/2011/11/28/launching-a-wpf-window-in-a-separate-thread-part-1/
But you should probably just move the creation of the thread and the call to its Show() method on to the UI thread:
else if(MyText.Content=="OpenNew")
this.Dispatcher.Invoke(new Action(() =>
InfoPanel sw = new InfoPanel();
sw.Show();
this.Close();
Please remember to mark helpful posts as answer.

Similar Messages

  • Missing options of "Enter Private Browsing" "Open new tab" and "Open new window" when right click (right context menu) firefox icon on taskbar

    Missing options of "Enter Private Browsing" "Open new tab" and "Open new window" when right click (right context menu) firefox icon on taskbar.
    i already tired complete uninstall and reinstall, but the options are still missing.
    print scr: http://www.freeimagehosting.net/9znkp
    Thank You in advance for help. Best regards

    Hello,
    ''jstavene wrote:''
    can find nothing under the tools menu for private browsing?
    Then it's not the same issue.
    If Firefox is set to '''Never remember history''', then you're in “permanent private browsing” mode, in which case the menu item ''Stop Private Browsing'' will be grayed out. Perhaps that's the case, and you don't find the menu item easy to see?
    * [[Settings for privacy, browsing history and do-not-track]]
    If that's not the case, then menu items can be hidden using the userChrome.css file. Check if it exists, and if it's there, rename it, then restart Firefox.
    * http://kb.mozillazine.org/UserChrome.css
    In Firefox Nightly (what will become Firefox 20), per-window private browsing has been added, so the menu item under the Tools menu is gone. It's been replaced by New Private Window under the File menu. I don't suppose it's very likely that you're using such a cutting-edge test version of Firefox though.
    If that doesn't solve the problem, since it's a different issue, it would be best if you would ask a new question.
    * https://support.mozilla.org/questions/new

  • Finder Windows always open new windows when clicking subfolders

    since i upgraded to 10.5.6, my finder windows only open new windows when I click on a subfolder. this is no matter what I do with the setting in preferences.
    Also, my finder windows no longer display the side bars with folder icons.
    I searched my library (and whole computer) for the finder preferences .plist file and can't find it. (was going to delete it and re-create it).
    Any ideas here?

    Thanks for the star.
    The default of Finder’s Find will not search that folder, but you can change the pulldown menu just beneath where it says Search, from Kind to System files by selecting Other from that menu and then scroll down the next window and check the box next to System files. You’ll then need to change the pulldown menu next to that to “include” instead of “don’t include.”
    The next time you do a search using Find, that pulldown menu will have System files as an option, if you think you might want to search for something in your home folder.

  • Enter file - new private window, FF opens new window, then immediately switches back to window that request was made from

    Hit file - new private window, FF opens new window (not private) for about 5 seconds, then immediately switches back to window that requested the new private window. This happens on three different machines at my location, all with Win 7.

    This happens in safe mode?
    *[http://mzl.la/MwuO4X Firefox in safe mode]
    Can you see what is the content of that tab?
    Also:
    *[http://mozilla.com/plugincheck Plugin check]

  • Folder icons keep reappearing whenever I make a new bookmark. closing window and opening new one eliminates them again. is there a fix for this?

    I asked this question months ago but have received no replies. I ran the original de-iconizer but as soon as I select "Bookmark this page" all the folder icons reappear. I can close the window and open a new one to get a de-iconized browser window but am looking for a fix for this.

    A possible cause is a problem with the file places.sqlite that stores the bookmarks and the history.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *https://support.mozilla.org/kb/Bookmarks+not+saved#w_fix-the-bookmarks-file
    You can also try to repair the places database with this extension:
    *https://addons.mozilla.org/firefox/addon/places-maintenance/

  • Using Struts, On submit button in child window, its opening new window.

    We are developing a project using Struts and BC4J. I am opening a child window(window.showmodaldialog) from main window using struts action. Actually Child window is a search kind of page. User will enter the search criteria and press the sumbit button. I want to display the search result in the same window using datatable when jboevent="submit". But its opening new window and displaying the result in that. However in <html:form>, Even I tried the target="_self".
    I am not sure wether the associated action in the <html:form> is forcing to open a new window.
    Similar kind of thing I am able to achieve in other similar search page, it its not a child window.
    Please let me know what I am missing.
    Thanks,
    Arvind

    So you want the search window to submit back to itself so you see the search field and a result list..?
    In pure Struts terms either using "_self" or the name of the popup window in the <html:form> tag will do the trick
    You need to make sure that the inital window that you created as the popup search window has a name in the first place - can you specify this with showModalDialog()?
    BTW isn't showModalDialog an IE only feature...

  • Having issues with gotoURL and open new window

    I am having trouble opening a new browser window with the gotoURL
    script. This is the current FormCalc that I am using.
    $host.gotoURL("http://www.google.com",1)
    I am wondering if this is working as expected? My PDF does not open
    into a new window in any browser or Adobe Reader. Is anybody aware of
    this problem? I have hyperlinks on my form that I am trying to get to
    open in a new window using FormCalc scripts.
    Appreciate any help. I am trying find out if this is bug, or is working
    as expected, or if there is another script to accomplish this?
    Thanks,
    Rebecca

    There are lots of customer applications that are based on Windows RAC. And as mentioned above, it is very well supported by Oracle.
    However, because of the security vulnerabilities of Windows, I've observed that most of the financial institutions and listed companies opt for unix based servers for all high profile applications and run only low to medium risk application on Windows.
    Regarding maintanence issues, I guess it's going to be pretty much the same; there shall always be lots of bugs, lots of patches and updates just like an yother software; doesn't really matter if you are on Unix or Windows systems. As long as you purchase support, it's all good.
    It's pretty much same concern regarding Grid Control on windows.
    Cheers.

  • Using Apple TV/Airplay for a full screen movie and opening new window on laptop

    When I have a full screen movie playing on my TV in AirPlay dual screen mode, and I open a new Safari window or my Mail, the window appears seemingly by default on top of the movie rather than coming up on my laptop monitor.  Is there a spot I can reset the default for new Safari windows and Mail windows to my laptop monitor, so they don't interrupt the movie on my TV?
    Background: my girls love Downton Abbey and Call the Midwife which I find terribly boring, and need to find something to do while the movies are playing rather than fall asleep! And you know what happens if Safari shows up over top of their beloved Downton! 

    it being mirror and many tv's being widescreen 16:9 and the screen of ios device not being widescreen this happen
    most tv's support having top and button chopped or streghed to fill the tv this is something one does with the tv's remote

  • Session and Open new window

    1. I have a problem to access my session variable at second file (null). I was simply the code as below:
    http://abc/test1.jsp
    <%
    session.setAttribute("user", "Test 1");
    %>
    http://abc/sample/test2.jsp
    <%
    String username=(String) session.getAttribute("user");
    out.print(username);
    %>
    2. How do I use jsp /jstl open a new window?

    gohgss wrote:
    1. I have a problem to access my session variable at second file (null). I was simply the code as below:Maybe you're doing something wrong somewhere else. The code looks OK.
    2. How do I use jsp /jstl open a new window?You can't. Use HTML or Javascript instead. The form and anchor tags (<form> and <a>) have a "target" attribute. If you set it to "_blank", then the form or link will be opened in a new window. With JS, just put window.open(url) somewhere in an "on*" attribute, e.g. onclick, onchange, etc.

  • Not able to open firefox, will open if I click on firefox icon, go to finder and open "new window". How can I get it to open up right away again. Thanks. RK

    When I double click on firefox, it will not open. I am able to open it by going to "file and clicking on "new window". It just happened today. Thanks. RK

    Do you mean https://addons.mozilla.org/en-us/firefox/addon/amazon-s3-organizers3fox/?
    Please update to Firefox 23, the version you have is horribly out of date and will have alot of problems. [[Update Firefox to the latest version]]

  • Close current gui and open another?

    how can i close the current gui and then open another? what would be a suitable way to so? so far i do it using the following code but it does not close the current window and it takes a couple of seconds to load the other gui screen..
       private void btn_registerActionPerformed(java.awt.event.ActionEvent evt) {                                            
             Register Register_gui = new Register();
             Register_gui.setTitle("Login");
             Register_gui.setSize(467, 460);
             Register_gui.getSize();
             Register_gui.setVisible(true);// TODO add your handling code here:
             new Login().setVisible(false);
        }     

    Instead of new Login().setVisible(false); use dispose();This assumes that the event handler is a member of the frame you want to close. If not, you'll have to provide the handler with a reference.

  • Firefox 30 will not open new windows maximized

    I use Firefox on 2 machines, one at home and one at work. I updated both to Firefox 30.
    My home machine, with Windows 7 opens new windows maximized.
    My work machine, however, will not open new windows maximized. It will only open them at the last remembered window size. I have tried deleting localstore.rdf and this does not solve the issue.
    The window will open maximized on Firefox 28 on the same machine.

    '''''[https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode Start Firefox in Safe Mode]''''' {web link}
    While you are in safe mode;
    Press the '''<Alt>''' or '''<F10>''' key to bring up the tool bar.
    Followed by;
    Windows; '''Tools > Options'''
    Linux; '''Edit > Preferences'''
    Mac; ''application name'' '''> Preferences'''
    Then '''Advanced > General.'''
    Look for and turn off '''Use Hardware Acceleration'''.
    Poke around safe web sites and see if there is still a problem. Then restart.

  • Closing and opening new financial year activities

    Hi everybody
    I want to know step by step process to close financial year and open new financial year with transaction codes in MM prospective only. i know only number ranges to be changed. i want to know what all the things to be done in step wise with T-code.

    Hai Rakesh,
    Month End Closing Activities in Finance
    1. Recurring Documents.
    a) Create Recurring documents
    b) Create Batch Input for Posting Recurring Documents
    c) Run the Batch Input Session
    2. Posting Accruals or Provisions entries at month end
    3. Managing the GR/IR Account-Run the GR/Ir Automatic Clearing
    4. Foreign Currency Open Item Revaluation-Revalue Open Items in
    AR.AP
    5. Maintain Exchange Rates
    6. Run Balance Sheets u2013Run Financial Statement Version
    7. Reclassify Payables and Receivables if necessary
    8. Run the Depreciation Calculation
    9. Fiscal Year Change of Asset Accounting if it is year end
    10. Run the Bank Reconciliation
    11. Open Next Accounting Period
    Period End Closing Activities in
    Controlling:
    What are the period end closing activities in controlling ?
    The following are the period end closing activities in Controlling:
    Repost CO Documents that was incorrectly posted
    Run Distribution or Assessment Cycles
    Run the Overhead Calculation in Product Costing
    Run the WIP Calculation in Product Costing
    Run the Variance Calculation in Product Costing
    Run the Settlement Calculation in Product Costing which will post all the
    WIP and variance to Finance and PA.
    Calculate FI Data for Transfer to Profit Center
    Transfer Balance Sheet Items like Recievables, Payables, Assets and
    Stock
    Run Results Analysis for Sales Order if applicable
    Run Settlement of Sales Orders to PA.
    Regards
    Madhu I

  • HTML-DB OAE Javascript to close current window and open a new window

    Hi everybody,
    We work with 1.6.
    What we want is to close the current window and open a new window with the URL mentionned in the window.open('http://www.cf.qc/pls/portal/PORTAL.....,'newwindow').
    The new window opening fires only once although we call it many times.
    Our javascript is:
    function closeTest()
    { alert('closeTest');
    if('&REQUEST.'=='QUITTER2'){     
    w = window.self;
    w.opener = w;
    w.close();
    window.open('http://www.cf.qc/pls/portal/PORTAL.home','newwindow','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
    We call it on our application attributes :
    OnLoad="closeTest()"
    Thanks. Bye.

    Try this on for size:
    I have included two functions.
    windowRebuild() - opens a new window, maximizes it based on the screen size, removes all toolbars, and then closes the old window.
    myLocation(appName, pageName) - builds a url referencing an HTMLDB application, specfic to what server you are currently on. Very useful when you have an application on 3 different servers(dev, test, prod servers), you wouldn't want the server name hardcoded if you plan to export the app to another server.
    Also, you need to be careful when using &APP_ID. I am not completely certain how that is resolved at runtime, but I've found it only works when the javascript is in the HTML Header of a page and not stored in the template of the page.
    <script language="JavaScript1.1" type="text/javascript">
      This functions is for internal application use.
      Examples of myLocation:
      url = myLocation('&APP_ID.', 'APP_PUBLIC_PAGE');
      url = myLocation('MY_APP_ALIAS', 'MY_PAGE_ALIAS');
      url = myLocation('184', '10');
    function myLocation(myApp, myPage){
      var myHost = location.host;
      var newURL;
      newURL = 'http://'+myHost+'/pls/htmldb/f?p='+myApp.toString()+':'+myPage.toString();
      return newURL;
    /*  Function windowRebuild()
    *   This function will open a new window and close the old window.
    *   This function will also maximize the new window and remove all toolbars.
    function windowRebuild(){
       if(window.name != 'myAppWin'){
        var url = myLocation('&APP_ID.', 'PAGE_ALIAS');
        var myWin = window.open(url,'myAppWin','toolbar=0,scrollbars=1,menubar=0,status=1,resizable=1,location=0');
        window.opener = 'x';
        window.close();
       if(window.name == 'myAppWin'){
        window.moveTo(0,0);
        window.resizeTo(screen.availWidth,screen.availHeight);
    </script>Let me know if that works or you need some more explanation.
    Chris

  • Why do my animated themes only work the first time I open the window? Every one that I have tried stops animating if I close the window and open a new one.

    The headline pretty much sums up my problem. Basically, I picked a few different animated themes to try out in the Add-Ons section to personalize my browser window. They look great initially, and in the window that is open when I actually enable the theme. However, if I close that window and open a new one, the theme is stationary and no longer animates.

    Sorry......I was just too impulsive. ( Maybe because it was 4 AM at Taiwan, and I was still trying to solve the problem= = )
    Although to install the add-on "Personas Shuffler" can solve the problem to me, I don't think it was the BEST solution. This evening, I read why the add-on "Personas Shuffler" was made, and found that the BEST solution is:
    1. Open a new tab, and type "about:config" at the URL bar, then search for "lightweightthemes" with the filter.
    2. Change the values of "lightweightThemes.persisted.footerURL" and "lightweightThemes.persisted.headerURL" from true to false( by double click on them).
    3. After doing so, restart Firefox and you will see it works! You don't have to install any add-on.

Maybe you are looking for

  • Illustrator freezes at startup

    Hi everyone, A while ago I installed Windows 7 along with my favourite adobe products and recently I installed Illustrator CS4, which went quite ok. But when I want to start Illustrator, it gets stuck at its orange loading screen. To be more precise:

  • Default setting of SAP GUI Status bar

    Hello all, Is there a way to set a default value of the precious combobox from the GUI status bar (the one showing System, Client, User, Program.....). I would like to set it to always display the SAP System. thanks.

  • I've just recently installed Snow Leopard. I opened Photoshop CS4 then went to quit it and it won't let me quit. It's greyed out. Any suggestions?

    I've just recently installed Snow Leopard. I opened Photoshop CS4 then went to quit it and it won't let me quit. It's greyed out. Any suggestions?

  • Combining Select Query

    Hi All, Please tell me how to combine the following 2 select queries:   SELECT  SINGLE konda                      FROM vbkd                         INTO v_konda                      WHERE vbeln EQ v_vbelv.   SELECT SINGLE traty                      F

  • Big One Off £200 charge on my monthly sim bill

    My average monthly sim bilss is around £12.However on my last bill I got a one off charge for £200!!!It was listed under 'One Off Charges' as a 'TM HS Zone D'.I have no idea what this and certailnly wasn't made by me. Does anyone know what this coud