Version

Adding Resource Washer to Your Page

Topic Overview

Purpose

This topic demonstrates how to add a ResourceWasher™ component to your application and use it for washing the colors defined in your resources.

Required background

You need to first read the following topics:

ResourceWasher Configuration Overview

Control configuration chart

The table below lists some of the configurable behaviors of the ResourceWasher component.

Configurable behavior

Configuration details

Configuration properties

Steps needed to add a ResourceWasher control to an application.

none

Configure the component.

WashColor Property

AutoWash Property

WashMode Property

SourceDictionary Property

WashGroup Property

Adding ResourceWasher to an application

  1. Add the Infragistics namespace.

    1. Add required NuGet packages

      In order to use a ResourceWasher in your application, you must add the Infragistics.WPF NuGet package to your project. For more information on setting up the NuGet feed and adding NuGet packages, you can take a look at the following documentation: NuGet Feeds.

    2. Add the Infragistics namespace

      In XAML:

      xmlns:ig="http://schemas.infragistics.com/xamlThemes"

      In Visual Basic:

      Imports Infragistics.Windows.Themes

      In C#:

      using Infragistics.Windows.Themes;
  2. Adding ResourceWasher component to an application.

    In XAML:

    <ig:ResourceWasher />

    In Visual Basic:

    Dim resourceWasher As ResourceWasher = New ResourceWasher()

    In C#:

    ResourceWasher resourceWasher = new ResourceWasher();

Modifying the ResourceWasher

The following table maps the desired configurations to property settings. The properties are directly accessed from the ResourceWasher class.

In order to…

Use this property:

And set it to…

A System.Windows.Media.Color of your choosing

A Boolean that determines if the process will start automatically

An enum value of type WashMode

A dictionary that contains the resources to be washed

A WashGroupCollection object

Modifying the ResourceWasher details

  1. Define the color that used in washing resources.

    An important part of setting up the ResourceWasher component is to set the color used in the process:

    In XAML:

    <ig:ResourceWasher WashColor="[your color]" />

    In Visual Basic:

    resourceWasher.WashColor = [your color]

    In C#:

    resourceWasher.WashColor = [your color];
  1. Set the moment the washing process will start.

    If you want the resources to be processed immediately after they are loaded then you set the AutoWash property to true:

    In XAML:

    <ig:ResourceWasher AutoWash="True" />

    In Visual Basic:

    resourceWasher.AutoWash = True

    In C#:

    resourceWasher.AutoWash = true;

    If you want to start the washing process manually, set the AutoWash property to false and call the WashResources method in your code:

    In Visual Basic:

    resourceWasher.WashResources()

    In C#:

    resourceWasher.WashResources();
  2. Set the type of the color change applied.

    There are two methods for color washing supported by the ResourceWasher – HueSaturationReplacement and SoftLightBlend. Set the WashMode property of the ResourceWasher to the method of your choice:

    In XAML:

    <ig:ResourceWasher WashMode="SoftLightBlend" />

    In Visual Basic:

    resourceWasher.WashMode = WashMode.SoftLightBlend

    In C#:

    resourceWasher.WashMode = WashMode.SoftLightBlend;
  1. Set the source dictionary to be used in the process

    In XAML:

    <ig:ResourceWasher.SourceDictionary>
        <ig:ResourceWasher Source="[your dictionary]" />
    <ig:ResourceWasher.SourceDictionary>

    In Visual Basic:

    resourceWasher.SourceDictionary = [your dictionary]

    In C#:

    resourceWasher.SourceDictionary = [your dictionary];
  1. Use different wash colors and modes for different elements in one dictionary.

    In order to wash different elements with different wash setting (or exclude some elements from washing), you must define elements in groups using the attached property ig:ResourceWasher.WashGroup. In order to exclude a group from washing you can set the ig:ResourceWasher.IsExcludedFromWash to true:

    In XAML:

    <Page.Resources>
        <SolidColorBrush x:Key="Background1" Color="Wheat"
            ig:ResourceWasher.WashGroup="WashGroup1"
            ig:ResourceWasher.IsExcludedFromWash="False" />
        <SolidColorBrush x:Key="Background2" Color="BlueViolet"
            ig:ResourceWasher.WashGroup="WashGroup2"
            ig:ResourceWasher.IsExcludedFromWash="False" />
        <SolidColorBrush x:Key="Background3" Color="Honeydew"
            ig:ResourceWasher.WashGroup="WashGroup3"
            ig:ResourceWasher.IsExcludedFromWash="True" />
        <SolidColorBrush x:Key="Background4" Color="Orange"
            ig:ResourceWasher.WashGroup="WashGroup4"
            ig:ResourceWasher.IsExcludedFromWash="False" />
    </Page.Resources>

    Once the wash groups are defined in the resources you can add them in a WashGroupCollection and set it to the component’s WashGroups property:

    In XAML:

    <ig:ResourceWasher WashColor="Red">
       <ig:ResourceWasher.WashGroups>
          <ig:WashGroupCollection>
             <!--This one will be washed in Red-->
             <ig:WashGroup Name="WashGroup1" />
             <!--This one will override the Red and will be washed in Blue-->
             <ig:WashGroup Name="WashGroup2" WashColor="Blue" />
             <!--This one will NOT be washed at all because it is defined as IsExcludedFromWash="True"-->
             <ig:WashGroup Name="WashGroup3" />
             <!--WashGroup4 will be washed in red as it is a part of the ResourceDictionary
             being Washed-->
          </ig:WashGroupCollection>
       </ig:ResourceWasher.WashGroups>
    </ig:ResourceWasher>

Following are some other topics you may find useful.