Reputation: 411
I'm trying to access a function or the UI components in a .XAML page that is loaded into a frame. In my MainPage I have a frame that is used to display different pages using...
Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(View::typeid));
I can access functions within the MainPage from the View page using...
View::View() : rootPage(MainPage::Current)
{
...
}
View::onClickBtnAdd(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
rootPage->ResetImageView();
}
void View::DoSomething(){
//do some stuff in the View page
}
This allows functions within MainPage.xaml.cpp to be accessed from View.xaml.cpp and works fine. I want to be able to access View.xaml.cpp from MainPage.xaml.cpp... something like the following.
MainPage::onImageTapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
{
View->DoSomething();
}
I've had a look at the documentation for Frame Class and it looks like SourcePageType is what I might need but I can't figure out how to use it. Any hints?
Upvotes: 0
Views: 98
Reputation: 717
You need to cast Frame->Content in your MainPage to your View type, and that should give you access to its public methods.
Upvotes: 1