Certificate and the correct answer to the question

I am preparing for an exam and studying questions. However, I have one question, which, in my opinion, is incorrect. Here's the question, where is the correct answer: D:

You are using Microsoft.NET Framework 4 to create a Windows Foundation Presentation (WPF). the application has a window called MainWindow, which has a StackPanel control name as the root element. You want to create a Button control that contains a TextBlock control with the Save property. You need to dynamically create control and add control to sp. What code segment should be written in the constructor class MainWindow

AND:

Button btn = new Button();
TextBlock text = new TextBlock();
text.Text = "Save";
btn.Content = text;
sp.DataContext = btn;

AT:

Button btn = new Button();
TextBlock text = new TextBlock();
text.Text = "Save";
btn.Content = text;
sp.Children.Add(btn);

WITH

Button btn = new Button();
TextBlock text = new TextBlock();
text.Text = "Save";
sp.Children.Add(btn);
sp.Children.Add(text);

D:

Button btn = new Button();
TextBlock text = new TextBlock();
text.Text = "Save";
btn.ContentTemplateSelector.SelectTemplate(text, null);
sp.Children.Add(btn);

In my opinion, the correct answer is B? Do you have any suffixes?

+5
source share
2

, . D , :

  • ContentTemplateSelector,
  • ContentTemplateSelector , ContentControl,
  • ContentTemplateSelector null, D NullReferenceException
+7

. , B. , , D .

+3

All Articles