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:

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:

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



Leave a Reply 5

Your email address will not be published. Required fields are marked *


Lord Vader

Lord Vader

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

Lord Vader

Lord Vader

assuming there is a text box called greeting in page1.xaml

Lord Vader

Lord Vader

StackPanel

/StackPanel

Lord Vader

Lord Vader

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