Sustitution NavigationService [SOLVED]

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
h_kos
Posts: 11
Joined: Wed Oct 28, 2015 11:30 pm

Sustitution NavigationService [SOLVED]

Postby h_kos » Wed Oct 28, 2015 11:53 pm

As there is no NavigationService pendant in Beta 5.1 I did all the navigationhandling myself (NavigateTo, Back, ...) and it works fine like proposed in one of your forum entries by adding a <Border .../> control to the XAML and substitute the Child-property each time you want to navigate to a new page or go back to the previous page on the back-stack.

I store my page-instances in a stack, pushing and poping the views/pages onto or from the stack. As I said it works fine. What I recognized is that when I pop a page from the stack and set the previous page from the stack as the Border control's child, it seems like all the button's click event handler are unsubscribed: the button-click event is not raised any more, but e.g. the Loaded-event of the page is still raised. Any ideas?


pseudo-code:

Code: Select all

Common:
...
Stack<Pages> TheStack;
Border ContentContainer;
...


Page1:

On Button-Click:
Page page2 = new Page2();
TheStack.Push(page2);
ContentContainer.Child = Page2;

// page2 is displayed


Page2:
On Button-Cancel click:

TheStack.Pop();
Page previousPage = TheStack.Peek();
MyContentProvier.Child=previousPage;

// --> landing on Page1 again, button's Click-event is not raised any more.

h_kos
Posts: 11
Joined: Wed Oct 28, 2015 11:30 pm

Re: Sustitution NavigationService

Postby h_kos » Thu Oct 29, 2015 2:13 am

A workaround is to attach an Loaded-eventhandler to the page.
In this eventhandler, attach the button-click event. But I assume that this behaviour will be the same for ALL eventhandlers (lostfocus, keydown, ...). So it is really only a temporary workaround.

Code: Select all

public LoginView()
        {
            this.InitializeComponent();           
            this.Loaded += LoginView_Loaded;
        }

        void LoginView_Loaded(object sender, RoutedEventArgs e)
        {
            this.BtnSettings.Click -= BtnSettings_OnClick;
            this.BtnSettings.Click += BtnSettings_OnClick;
        }
...
}



At the moment it seems only button eventhandlers are effected.

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Sustitution NavigationService

Postby JS-Support @Userware » Fri Oct 30, 2015 11:43 am

Hello,

Thanks for reporting this issue.

It has now been fixed in the Beta 5.2, available from:
http://forums.cshtml5.com/viewtopic.php?f=2&t=200

Thanks.
Regards,
JS-Support

h_kos
Posts: 11
Joined: Wed Oct 28, 2015 11:30 pm

Re: Sustitution NavigationService [SOLVED]

Postby h_kos » Sun Nov 01, 2015 11:18 pm

Perfect! thank you for the fast reply!

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Sustitution NavigationService [SOLVED]

Postby JS-Support @Userware » Mon Nov 02, 2015 1:14 am

You are welcome :-)


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 32 guests