xamluwpstaticresource

Access static resource property from xaml?


I'm trying to access a static resource's property:

<ResourceDictionary>
    <FeatureControl
        x:Key="FeatureControl"
        IsSweetFeatureEnabled="True">

    <SweetFeature IsEnabled="{StaticResource FeatureControl.IsSweetFeatureEnabled}"/>
</ResourceDictionary>

But this gives me a runtime error.

All the posts I've found are dealing with wpf and not uwp.

I know I can pass FeatureControl and access the property from within the SweetFeature class, but the SweetFeature class does not need know about what other features are enabled.

Any ideas?


Edit

This is how the property is defined:

public class SweetFeature
{
    public bool IsEnabled { private get; set; }
    ...
}

Solution

  • This should work for the binding:

    IsEnabled="{Binding IsSweetFeatureEnabled, Source={StaticResource FeatureControl}}"