Click here to Skip to main content
15,896,500 members
Articles / Desktop Programming / WPF

WPF Fallback Brush

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
9 Nov 2009CPOL5 min read 24.1K   126   11  
A special brush using binding and converters to achieve graceful degradation.
<Window x:Class="FallbackBrushDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:c="clr-namespace:FallbackBrushDemo"
        Title="MainWindow" Height="350" Width="525">
    <Grid x:Name="root"  Background="{c:RemoteBrush PrimaryBrush=Pink, SecondaryBrush=Orange}">
        <Button Content="Button" Height="154" Foreground="White" HorizontalAlignment="Left" Margin="95,77,0,0" Name="button1" VerticalAlignment="Top" Width="304" Click="button1_Click">
            <Button.Background>
                <c:RemoteBrush>
                    <c:RemoteBrush.PrimaryBrush>
                        <SolidColorBrush Color="Yellow"></SolidColorBrush>
                    </c:RemoteBrush.PrimaryBrush>
                    <c:RemoteBrush.SecondaryBrush>
                        <LinearGradientBrush>
                            <GradientStop Color="LimeGreen" Offset="0"></GradientStop>
                            <GradientStop Color="DarkGreen" Offset="0.9"></GradientStop>
                        </LinearGradientBrush>
                    </c:RemoteBrush.SecondaryBrush>
                </c:RemoteBrush>
            </Button.Background>
        </Button>
    </Grid>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions