How to: Call a Page Function

How to: Call a Page Function

This example shows how to call a page function from a Extensible Application Markup Language (XAML) page.

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);

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"
    <Hyperlink Name="callPageFunctionHyperlink" Click="callPageFunctionHyperlink_Click">Call Page Function</Hyperlink>

void callPageFunctionHyperlink_Click(object sender, RoutedEventArgs e)
    // Call a page function
    GetStringPageFunction pageFunction = new GetStringPageFunction("initialValue");

© 2015 Microsoft