I have the following static method in an class called "Article" :
public static ObservableCollection<Article> GetObservableCollection() { ... }
And I'd like to bind this directly to the ItemsSource property of a ComboBox but in the XAML not in code, I can't find the right syntax.
It should look something like this I think (EmacGbscCore is the assembly containing Article object) :
ItemsSource="{Binding Source={x:Static EmacGbscCore:Article.GetObservableCollection}}"
Thank in advance for your help.
You need to declare an ObjectDataProvider
in the resources:
<ObjectDataProvider x:Key="data"
ObjectType="{x:Type EmacGbscCore:Article}"
MethodName="GetObservableCollection" />
And use this as the source of your binding:
ItemsSource"{Binding Source={StaticResource data}}"