Northwoods.GoSilverlight 1.2.2 Assembly
BooleanBrushConverter Class
Members  See Also  Send Feedback
Northwoods.GoXam Namespace : BooleanBrushConverter Class

Convert a boolean to one of two Brushes.

Syntax

Visual Basic (Declaration) 
Public Class BooleanBrushConverter 
   Inherits Converter
   Implements IValueConverter 
C# 
public class BooleanBrushConverter : Converter, IValueConverter  

Remarks

You can specify a brush for when the boolean is True and another one for when the boolean is False, either by setting the TrueBrush or FalseBrush properties, or by setting the TrueColor or FalseColor properties which will also set the corresponding brush property to a SolidColorBrush of that color.

Typically you will create an instance (or two) of this converter class as resources. For example:

            <go:BooleanBrushConverter x:Key="theBooleanBrushConverter" TrueColor="DodgerBlue">
              <go:BooleanBrushConverter.FalseBrush>
                <LinearGradientBrush . . .>
                   . . .
                </LinearGradientBrush>
              </go:BooleanBrushConverter.FalseBrush>
            </go:BooleanBrushConverter>
            

One possible use for this converter is to indicate selection:

            <DataTemplate x:Key="NodeTemplate2">
              <Border BorderBrush="Gray" BorderThickness="1"
                      Background="{Binding Path=Part.IsSelected, Converter={StaticResource theBooleanBrushConverter}}"
                      go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}">
                <StackPanel Orientation="Vertical">
                  <Ellipse Fill="Blue" Width="20" Height="20" HorizontalAlignment="Center"
                           go:Node.LinkableFrom="True" go:Node.LinkableTo="True" Cursor="Arrow"
                           go:Node.FromSpot="AllSides" go:Node.ToSpot="AllSides"/>
                  <TextBlock x:Name="Text" Text="{Binding Path=Data.Key}" HorizontalAlignment="Center" />
                </StackPanel>
              </Border>
            </DataTemplate>
            
When the node is not selected, the background is a linear gradient brush. When the node is selected, the background is a solid DodgerBlue.

By default true converts to the system highlight color/brush (typically bluish) and false converts to the system highlight text color/brush (typically white).

Inheritance Hierarchy

System.Object
   Northwoods.GoXam.Converter
      Northwoods.GoXam.BooleanBrushConverter

Requirements

See Also

© 2010 All Rights Reserved.