views:

136

answers:

1

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>

+1  A: 

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
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