You are developing an application by using Silverlight 4 and Microsoft .NET Framework 4.
You create a control named MyControl in the application. Each instance of the control contains a list of FrameworkElement objects.
You add the following code segment. (Line numbers are included for reference only.)
01 public class MyControl : Control
02 {
03
04 public List<FrameworkElement> ChildElements
05 {
06 get {
07 return List<FrameworkElement>)GetValue(MyControl.ChildElementsProperty);
08 }
09 }
10
11 public MyControl()
12 {
13
14 }
15 static MyControl()
16 {
17
18 }
19 }
You need to create the ChildElementsProperty dependency property. You also need to initialize the property by using an empty list of FrameworkElement objects.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
A.
Add the following code segment at line 03.
public static readonly DependencyProperty ChildElementsProperty =
DependencyProperty.Register(“ChildElements”, typeof(List<FrameworkElement>),
typeof(My Control), new PropertyMetadata(new List<FrameworkElement>()));
B.
Add the following code segment at line 03.
public static readonly DependencyProperty ChildElementsProperty =
DependencyProperty.Register(“ChildElements”, typeof(List<FrameworkElement>),
typeof(My Control), new PropertyMetadata(null));
C.
Add the following code segment at line 13.
SetValue(MyControl.ChildElementsProperty, new List<FrameworkElement>());
D.
Add the following code segment at line 17.
ChildElementsProperty =
DependencyProperty.Register(“ChildElements”, typeof(List<FrameworkElement>),
typeof(MyControl), new PropertyMetadata(new List<FrameworkElement>()));