I'm daft, that's the problem:
private static void UpdateComboDropdown(string comboboxName, DataGrid dataGrid)
{
/* *
* I think CurrentItem is used in this instance because
* it's a single cell selection mode?
* *
* I CBA to check.
* */
var selectedRow = dataGrid.ItemContainerGenerator.ContainerFromItem(dataGrid.CurrentItem) as DataGridRow;
if (selectedRow != null)
{
DataGridCellsPresenter presenter = GetVisualChild<DataGridCellsPresenter>(selectedRow);
if (presenter != null)
{
var visualComboBox = presenter.FindChild<ComboBox>(comboboxName);
if (visualComboBox != null)
{
var binding = visualComboBox.GetBindingExpression(ComboBox.ItemsSourceProperty);
if (binding != null)
binding.UpdateTarget();
}
var popupPart = visualComboBox.FindChild<Popup>("PART_Popup");
if (popupPart != null && popupPart.Child != null)
{
//Popup has one child, reports zero children, so: search on its child.
var previous = popupPart.Child.FindChild<Button>("PreviousButton");
if (previous != null)
{
var previousIsEnabledBinding = previous.GetBindingExpression(Button.IsEnabledProperty);
if (previousIsEnabledBinding != null)
previousIsEnabledBinding.UpdateTarget();
}
var next = popupPart.Child.FindChild<Button>("NextButton");
if (next != null)
{
var nextIsEnabledBinding = next.GetBindingExpression(Button.IsEnabledProperty);
if (nextIsEnabledBinding != null)
nextIsEnabledBinding.UpdateTarget();
}
}
};
}
}
I was telling it to update the ItemsSource of the combobox, not the other way around. As for why the relationship isn't automatically updating, I don't know. Now to find out how to update the constituent elements of the combobox controls in its dropdown. Likely will involve getting its PART_Popup, then the next/previous buttons and their respective bindings. This is annoying.
Edit: Updated the answer with the full solution.