Northwoods.GoWPF 2.2.4 Assembly
BooleanBrushConverter Class
Members 

Convert a boolean to one of two Brushes.
Syntax
<ValueConversionAttribute(SourceType=System.Boolean, 
   TargetType=System.Windows.Media.Brush, 
   ParameterType=)>
Public Class BooleanBrushConverter 
   Inherits Converter
   Implements System.Windows.Data.IValueConverter 
[ValueConversionAttribute(SourceType=System.Boolean, 
   TargetType=System.Windows.Media.Brush, 
   ParameterType=)]
public class BooleanBrushConverter : Converter, System.Windows.Data.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

Reference

BooleanBrushConverter Members
Northwoods.GoXam Namespace

 

 


© Northwoods Software 2017. All Rights Reserved.

Send Feedback