Chaitanya
Chaitanya

Reputation: 11

How to get the Elements defined under Control Template in runtime in WPF

How to get the Elements defined under Control Template in runtime in WPF

Upvotes: 1

Views: 603

Answers (2)

Rachel
Rachel

Reputation: 132568

You could probably use the VisualTreeHelper to find children. For example:

for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parentElement); i++)
{
    var childElement = VisualTreeHelper.GetChild(parentElement, i);
    // Do something with object here
}

Upvotes: 2

Kishore Kumar
Kishore Kumar

Reputation: 21863

use the Template Properties FindName method

Control.Template.FindName

Upvotes: 2

Related Questions