0

How can I change the automationID Property of the editable TextBox inside an editable ComboBox in XAML?

When I set the automationID on the ComboBox it does not affect the editable TextBox inside of it. How can I access the editable TextBox and change it through XAML?

My XAML ComboBox code:

<ComboBox Name="TestCombo"Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" IsEnabled="{Binding IsEditable}" Visibility="{Binding ComboBoxVisible}" Text="{Binding Value,UpdateSourceTrigger=PropertyChanged}" IsEditable="true" LostKeyboardFocus="LostFocusEventHandler">
Turbine
  • 15
  • 3
  • I think [this](https://stackoverflow.com/questions/14617061/is-there-a-way-to-set-the-automationid-of-an-object-without-using-xaml) answer may help you. – Dan Csharpster Dec 21 '20 at 19:56
  • The editable TextBox is not defined in the code so I can't access it there. It is set because of the IsEditable="true" property of my ComboBox. That generates a TextBox inside the ComboBox that I can type text in. See the "PART_EditableTextBox" [here](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/combobox-styles-and-templates?view=netframeworkdesktop-4.8) – Turbine Dec 22 '20 at 09:47
  • 1
    @Turbine: If you want to access it "through XAML", you need to define your own custom control template. If you don't want to do this, you could programmatically get a reference to the `TextBox` at runtime. – mm8 Dec 22 '20 at 15:48
  • Ok thanks for the info. Do you know how I can get that `TextBox` reference during runtime? – Turbine Dec 22 '20 at 15:58

0 Answers0