tags:

views:

79

answers:

1

Is it possible to bind the alpha value of an element to a slider?

For example, this is code that allows the slider to change the height and top position of the element, but what is the syntax to control the alpha value in the Background attribute of the border?

<Window x:Class="WpfApplication25.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid Background="Tan">
        <StackPanel>
            <Canvas>
                <Border Background="#{Binding ElementName=theSlider, Path=Value}ffff00" 
            Canvas.Left="40" 
            Canvas.Top="{Binding ElementName=theSlider, Path=Value}" 
            CornerRadius="5" 
            BorderBrush="Brown"
            BorderThickness="1"
            >
                    <Rectangle 
            Height="{Binding ElementName=theSlider, Path=Value}"
            Width="50"
            />
                </Border>
            </Canvas>
        </StackPanel>

        <Slider Name="theSlider" HorizontalAlignment="Left" Width="200" Minimum="10" Maximum="200" Cursor="Hand"/>

    </Grid>
</Window>
A: 

Bind to the "Opacity" property, don't forget to set the slider minimum to 0 and maximum to 1

Nir
Perfect, thanks!
Edward Tanguay
Is not working for me.
Adam