Which code segment should you add to the code-behind file?

You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You write the following code fragment.
<StackPanel>
<StackPanel.Resources>
<Style TargetType=”{x:Type Button}”>
<EventSetter Event=”Click” Handler=”ButtonHandler”/>
</Style>
</StackPanel.Resources>
<Button Name=”OkButton”>Ok</Button>
<Button Name=”CancelButton” Click=”CancelClicked”>Cancel</Button>
</StackPanel>
You need to ensure that the ButtonHandler method is not executed when the user clicks the CancelButton button.
Which code segment should you add to the code-behind file?

You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You write the following code fragment.
<StackPanel>
<StackPanel.Resources>
<Style TargetType=”{x:Type Button}”>
<EventSetter Event=”Click” Handler=”ButtonHandler”/>
</Style>
</StackPanel.Resources>
<Button Name=”OkButton”>Ok</Button>
<Button Name=”CancelButton” Click=”CancelClicked”>Cancel</Button>
</StackPanel>
You need to ensure that the ButtonHandler method is not executed when the user clicks the CancelButton button.
Which code segment should you add to the code-behind file?

A.
private void CancelClicked(object sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
btn.Command = null;
}

B.
private void CancelClicked(object sender, RoutedEventArgs e) {
Button btn = (Button)sender;
btn.IsCancel = true;
}

C.
private void CancelClicked(object sender, RoutedEventArgs e) {
e.Handled = true;
}

D.
private void CancelClicked(object sender, RoutedEventArgs e) {
e.Handled = false;
}



Leave a Reply 0

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