PrepAway - Latest Free Exam Questions & Answers

How should you complete the code?

DRAG DROP
You are developing a Universal Windows Platform (UWP) app. In MainPage.xaml, you have the following
markup.

You need to create an event handler for the app. How should you complete the code? To answer, drag the
appropriate code elements to the correct targets. Each element may be used once, more than once, or not at
all.

You may need to drag the split bar between panes or scroll to view content.
Select and Place:

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:
Example: Peer-to-peer navigation between two pages
private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(Page2), name.Text);
}

https://msdn.microsoft.com/en-us/library/windows/apps/mt465735.aspx

5 Comments on “How should you complete the code?

  1. Lord Vader says:

    When the Click event of the HyperlinkButton in mainpage.xaml calls this.Frame.Navigate(typeof(Page1), name.Text), the name.Text property is passed to Page1, and the value from the event data can be used for the message displayed on the page.

    as in:
    In the Page1.xaml code-behind file, override the OnNavigatedTo method with the following:
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
    if (e.Parameter is string && !string.IsNullOrWhiteSpace((string)e.Parameter))
    {
    greeting.Text = $”Hi, {e.Parameter.ToString()}”;
    }
    else
    {
    greeting.Text = “Hi!”;
    }
    base.OnNavigatedTo(e);
    }




    0



    0
  2. Lord Vader says:

    StackPanel>
    TextBlock HorizontalAlignment=”Center” Name=”greeting”/>
    HyperlinkButton Content=”Click to go to page 1″
    Click=”HyperlinkButton_Click”
    HorizontalAlignment=”Center”/>
    /StackPanel>




    0



    0

Leave a Reply