Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set an AutomationProperties.AutomationId in code behind

I have a WPF application that has a few legacy panels that were written mostly with code behind. I need to set the AutomationProperties.AutomationId for the controls on the panel. For example, this Checkbox

CheckBox myCheckbox = new CheckBox();

How can I set AutomationProperties.AutomationId?

like image 920
doobop Avatar asked Jul 13 '14 00:07

doobop


1 Answers

myCheckbox.SetValue(AutomationProperties.AutomationIdProperty, "checkBoxAutoID");
like image 122
d.moncada Avatar answered Sep 27 '22 18:09

d.moncada