locked
Best Practice? Opening and closing windows... RRS feed

  • Question

  • Currently in my WPF (C#) application I am opening and closing about 6 different windows based on the buttons being clicked, etc. When a button is pressed it Shows the next window and Closes the current window. I have a blue background and in between the window transition I get a little flash of black before the new window opens. How do I get rid of that? I've tried to do fade out and fade ins of the old and new window but I still get that flash of a window closing and the new window showing. Should I be opening and closing windows like this, or have all my functionality in one window? Is there a better way? And how do I get rid of that little flash?
    Tuesday, September 9, 2008 2:05 PM

Answers

  • HI,

    I think you are intrested in doing things in a sequence and therefore you can use Pages in WPF instead of creating a new window each time.
    Wednesday, September 10, 2008 8:32 AM
  • To navigate between pages you can use hyperlink tag in XAML.


    <Hyperlink NavigateUri="Page2.xaml">Page 2</Hyperlink>

    use a TextBlock inside your button and palce the above code inside it.
    eg:

    <button>
    <TextBlock
    >
        <
    Hyperlink NavigateUri="Page2.xaml">Page2</Hyperlink
    >
    </
    TextBlock
    >
    </button>

    Thursday, September 11, 2008 8:37 AM

All replies

  • HI,

    I think you are intrested in doing things in a sequence and therefore you can use Pages in WPF instead of creating a new window each time.
    Wednesday, September 10, 2008 8:32 AM
  • How can I switch between pages?

    For example if I wanna click a button and the the page changes to the next? Cant find it in the triggers menu  :/
    Wednesday, September 10, 2008 9:19 AM
  • To navigate between pages you can use hyperlink tag in XAML.


    <Hyperlink NavigateUri="Page2.xaml">Page 2</Hyperlink>

    use a TextBlock inside your button and palce the above code inside it.
    eg:

    <button>
    <TextBlock
    >
        <
    Hyperlink NavigateUri="Page2.xaml">Page2</Hyperlink
    >
    </
    TextBlock
    >
    </button>

    Thursday, September 11, 2008 8:37 AM
  • Use this code if you don't want to use Hyperlink for navigation,  
    //Code behind in Page1.xaml.vb

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click

            Dim nav As NavigationService

            nav = NavigationService.GetNavigationService(Me)

            nav.Navigate(New System.Uri("Page2.xaml", UriKind.RelativeOrAbsolute))

    End Sub

    • Edited by Jain Ashish Friday, September 12, 2008 9:30 AM
    Friday, September 12, 2008 9:27 AM
  •  I tried the code that was written here but it locks my application up when I try to "navigate" to another page. What am I missing here?

    Again I am using a full screen WPF application.
    Thursday, September 25, 2008 7:38 PM
  • Ok, I think I understand a little better after viewing a page tutorial.

    All of my pages are Windows. I have to have them as Windows because I need to be able to have the Window maximized with not ability to resize or close the Window (so that I can lock it down).

    My question is that I'm trying to do a smooth navigation from window to window but when I open one and close the other I get a little black flash before the window completely closes. Am I just out of luck, do I have to use pages? I do not want that little navigation menu at the top of my window.

    Thanks for your help.
    Thursday, September 25, 2008 8:07 PM