How to: Call a Page Function
This example shows how to call a page function from a Extensible Application Markup Language (XAML) page.
Example
You can navigate to a page function using a uniform resource identifier (URI), just as you can when you navigate to a page. This is shown in the following example.
// Navigate to a page function like a page
Uri pageFunctionUri = new Uri("GetStringPageFunction.xaml", UriKind.Relative);
this.NavigationService.Navigate(pageFunctionUri);
If you need to pass data to the page function, you can create an instance of it and pass the data by setting a property. Or, as the following example shows, you can pass the data using a non-default constructor.
<Page x:Class="UsingPageFunctionsSample.CallingPage"
xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
Title="CallingPage"
>
<Hyperlink Name="callPageFunctionHyperlink" Click="callPageFunctionHyperlink_Click">Call Page Function</Hyperlink>
</Page>
void callPageFunctionHyperlink_Click(object sender, RoutedEventArgs e)
{
// Call a page function
GetStringPageFunction pageFunction = new GetStringPageFunction("initialValue");
this.NavigationService.Navigate(pageFunction);
}