Reputation: 205
I want to pass navigationservice to my user control. At my application side
<myControl:Test NavigationService="{Binding NavigationService}"/>/>
at my Usercontrol CS side
public NavigationService NavigationService { get; set; }
but it dosent seems to work,application crashes as soon as it loads.
Upvotes: 1
Views: 1080
Reputation: 1139
That's really harsh... Alright, You haven't mentioned this, but I suppose, that you try to solve the problem of navigating from UserControl to other page/uc(is it true?).
A couple of edits:
If you really do want to use it with UserControl, you should transfer an instance of page to control. But, in my experience, usually, this is not required. I would rather recommend to do in this way:
In your UserControl you will most definitely have the controls with tap/click events. No need to describe their logic in user control class. When you add the user control to page, you should declare it there. Like:
someUserControl.buttonNavigate.MouseLeftButtonUp += new MouseButtonEventHandler(buttonNavigate_Click);
And then you can use navigation service.
NavigationService.Navigate(new Uri(...));
That's the easiest solution. Hope it helps.
There are another ones, but I hope this one will solve the problem.
Upvotes: 1