Friday, 2 May 2014

WPF binding to static property

Just so I don't forget again, here's how it's done...

xmlns:ValueConverters="clr-namespace:ValueConverters;assembly=Controls"
xmlns:Services="clr-namespace:Infrastructure.Interface.Services;assembly=Infrastructure.Interface"

...

        <ValueConverters:BooleanToVisibilityConverter2 x:Key="booleanToVisibilityConverter2" />
    </ResourceDictionary>

</UserControl.Resources>

...

<StackPanel x:Name="MyStackPanel"
            Orientation="Vertical"
            Visibility="{Binding Source={x:Static Services:UserPreferencesService.Instance}, Path=UseWebAssignment, Converter={StaticResource booleanToVisibilityConverter2}, ConverterParameter=true}">

No comments:

Post a Comment

Android mediaserver process killing battery life

If this happens to you, then do the following Force stop on Settings, Applications, All, Media Storage. Clear Cache and Clear Data, fo...