You could refer to the method below to see if it is what you need.
Xaml:
<Grid>
<ComboBox Name="cb" Loaded="cb_Loaded" Height="50" Width="100" >
<ComboBoxItem>Item1</ComboBoxItem>
<ComboBoxItem>Item2</ComboBoxItem>
<ComboBoxItem>Item3</ComboBoxItem>
</ComboBox>
</Grid>
Codebehind:
private T FindVisualChildByName<T>(DependencyObject parent, string name) where T : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
{
var child = VisualTreeHelper.GetChild(parent, i);
string controlName = child.GetValue(Control.NameProperty) as string;
if (controlName == name)
{
return child as T;
}
else
{
T result = FindVisualChildByName<T>(child, name);
if (result != null)
return result;
}
}
return null;
}
private void cb_Loaded(object sender, RoutedEventArgs e)
{
Popup popup = FindVisualChildByName<Popup>((sender as DependencyObject), "PART_Popup");
Border border = FindVisualChildByName<Border>(popup.Child, "DropDownBorder");
border.BorderBrush = Brushes.Red;
}
The result:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our [documentation][5] to enable e-mail notifications if you want to receive the related email notification for this thread.
[5]: https://learn.microsoft.com/en-us/answers/articles/67444/email-notifications.html