0

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>

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Jake Pearson
  • 27,069
  • 12
  • 75
  • 95

1 Answers1

1

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();
}
Wallstreet Programmer
  • 9,567
  • 3
  • 37
  • 52
  • That was close, UserInterfaceHelper is static so I just reloaded the drop down based on the event you suggested. Is there a way to do this with XAML? – Jake Pearson Jun 17 '09 at 19:02