Answers

Question and Answer:

  Home  WPF

⟩ How can I set an attached property in code?

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

 202 views

More Questions for you: