Windows Presentation Foundation (WPF) Question:
Download Job Interview Questions and Answers PDF
How can I set an attached property in code?
Answer:
The following example shows how you can set an attached property in code.
[C#]
DockPanel myDockPanel = new DockPanel();
CheckBox myCheckBox = new CheckBox();
myCheckBox.Content = "Hello";
myDockPanel.Children.Add(myCheckBox);
DockPanel.SetDock(myCheckBox, Dock.Top);
[C#]
DockPanel myDockPanel = new DockPanel();
CheckBox myCheckBox = new CheckBox();
myCheckBox.Content = "Hello";
myDockPanel.Children.Add(myCheckBox);
DockPanel.SetDock(myCheckBox, Dock.Top);
Download WPF Interview Questions And Answers
PDF
Previous Question | Next Question |
How can I mark the default value of a custom dependency property to be false? | How can I use an application resource? |