Reputation: 70327
This is my XAML:
ItemsSource="{x:Static app:HealthCheckSystemCategoryLookup.All}
Is there a way to make HealthCheckSystemCategoryLookup.All a function instead of a property?
Upvotes: 2
Views: 815
Reputation: 38353
Why not just bind to a property which calls the method in its Getter.
public IEnumberable<object> Data
{
get
{
return All();
}
}
Upvotes: 1
Reputation: 59149
No, x:Static
can only handle enum members, properties, and fields. You can use ObjectDataProvider
if you want to bind to the result of a method call. You would do something like this:
<Window.Resources>
<ObjectDataProvider
x:Key="Data"
ObjectType="app:HealthCheckSystemCategoryLookup"
MethodName="All"/>
</Window.Resources>
<ListBox ItemsSource="{Binding Source={StaticResource Data}}" />
Upvotes: 3