Trial helper

Using samples:
<ListBoxItem IsEnabled="{Binding DisabledOnTrial, Source={StaticResource TrialHelper}}" />
<TextBlock Visibility="{Binding VisibleOnTrial, Source={StaticResource TrialHelper}}" />

How to use

1. Add instance of TrialHelper to recources.
App.xaml:
<Application 
    x:Class="MSPToolkitSampleApp.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:msput="clr-namespace:MSPToolkit.Utilities;assembly=MSPToolkit">

    <!--Application Resources-->
    <Application.Resources>
        <msput:TrialHelper x:Key="TrialHelper"/>
    </Application.Resources>
<!--other code-->
<Application/>

And than use bindings in your xaml
<StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Button Content="Disabled in trial" IsEnabled="{Binding DisabledOnTrial, Source={StaticResource TrialHelper}}"/>
            <TextBlock Text="Hidden in trial" Visibility="{Binding CollapsedOnTrial, Source={StaticResource TrialHelper}}" Margin="12,0" FontSize="{StaticResource PhoneFontSizeMedium}"/>
            <TextBlock Text="Visible in trial" Visibility="{Binding VisibleOnTrial, Source={StaticResource TrialHelper}}" Margin="12,0" FontSize="{StaticResource PhoneFontSizeMedium}"/>
</StackPanel>

And you still can check current trial status from code.
if (MSPToolkit.Utilities.TrialHelper.IsTrial)
{
    // Do something
 }

Testing

Its difficult to check how you trial will work. This helper has static property IsAlwaysTrial when set to true helper will work like in trial mode.
MSPToolkit.Utilities.TrialHelper.IsAlwaysTrial = true;

Last edited Jan 21, 2012 at 2:28 PM by ad1Dima, version 2

Comments

No comments yet.