Question

How do I go about getting an ObjectDataProvider to get triggered each time a combo box is expanded instead of just one time?

<UserControl.Resources>
    <ObjectDataProvider x:Key="possibleExpressionValues"
                MethodName="GetWatchVariableNames" 
                ObjectType="{x:Type mu:UserInterfaceHelper}" IsInitialLoadEnabled="False">
    </ObjectDataProvider>
</UserControl.Resources>

<Grid>
    <ComboBox IsEditable="True" Text="{Binding ID}" ItemsSource="{Binding Source={StaticResource possibleExpressionValues}}" VerticalAlignment="Top" />
</Grid>

Was it helpful?

Solution

With ObjectDataProvider get triggered, do you mean you want a fresh UserInterfaceHelper object created?

In that case, hook up the DropDownOpened event of the combobox to following method.

private void ComboBox_DropDownOpened(object sender, EventArgs e)
{
  ObjectDataProvider odp = Resources["possibleExpressionValues"] as ObjectDataProvider;
  odp.ObjectType = null;
  odp.ObjectInstance = new UserInterfaceHelper();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top