Link to home
Start Free TrialLog in
Avatar of innovasoft
innovasoft

asked on

OuterGlowBitmapEffect in Silverlight?

hi everybody

I'm quite new to Silverlight and I've got a (maybe stupid?) question. I'd like to have an animation on a label when you move your mouse over it. It should start to glow (and stop that when mouse leaves). I was looking for such an effect and I found this one:

OuterGlowBitmapEffect
http://msdn.microsoft.com/en-us/library/ms752037(v=vs.90).aspx

But it seams, that Silverlight doesn't support such BitmapEffects. Am I right? And how could I do that in another way? (Btw. I don't have Expression Blend)
Avatar of saragani
saragani

      <TextBox Width="200" Height="23" Text="Hello World">
            <TextBox.Effect>
                <DropShadowEffect ShadowDepth="0" BlurRadius="30" Opacity="1" Color="Blue" />
            </TextBox.Effect>
        </TextBox>



Since .Net 4.0 WPF also have Effect.
BitmapEffect works on Software and doesn't use hardware acceleration... But Effect does.

Effect also in WPF have Blur and DropShadow.

OuterGlow is somewhat based on DropShadow, and you should be able to create all the BitmapEffect by those 2 Effects.
Hi, did you find my answer useful?
Avatar of innovasoft

ASKER

hi

thanks a lot for your answer. I couldn't test it yet. I will this evening and let you know
that's exactly the effect I wanted to have. Thank you very much!

But now, I need this effect to fade in on MouseEnter and to fade out on MouseLeave. I have no idea how I could do that?

Thank you for your help
I would put my guess on visual state manager.

If you can't get your hands and your legs from it, then post back
ASKER CERTIFIED SOLUTION
Avatar of saragani
saragani

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hm... i tried this, but I get a lot of errors. I created a new project called SilverlightOuterGlow with following XAML in the MainPage:


<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" x:Class="SilverlightOuterGlow.MainPage"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="CommonStates">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:1"/>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="NormalState"/>
                <VisualState x:Name="MouseOverState">
                    <Storyboard>
                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)" Storyboard.TargetName="textBox" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <TextBox x:Name="textBox" Width="200" Height="23" Text="Hello World">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseEnter">
                    <ei:GoToStateAction StateName="MouseOverState"/>
                </i:EventTrigger>
                <i:EventTrigger EventName="MouseLeave">
                    <ei:GoToStateAction StateName="NormalState"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <TextBox.Effect>
                <DropShadowEffect ShadowDepth="0" BlurRadius="30" Opacity="0" Color="Blue" x:Name="glowEffect"/>
            </TextBox.Effect>
        </TextBox>
    </Grid>
</UserControl>

Open in new window


then I get these errors:

The property 'Triggers' does not exist on the type 'TextBox' in the XML namespace 'http://schemas.microsoft.com/expression/2010/interactivity'  (line 26)

The tag 'EventTrigger' does not exist in XML namespace 'http://schemas.microsoft.com/expression/2010/interactivity'. (line 27)

The tag 'GoToStateAction' does not exist in XML namespace 'http://schemas.microsoft.com/expression/2010/interactions'. (line 28)

The tag 'EventTrigger' does not exist in XML namespace 'http://schemas.microsoft.com/expression/2010/interactivity'. (line 30)

The tag 'GoToStateAction' does not exist in XML namespace 'http://schemas.microsoft.com/expression/2010/interactions'. (line 31)

Hi, I forgot to mention that you need to add reference to
System.windows.interactivity
And
Microsoft.expression.interactions. (or something like that)
hm, I can't find these references. I just have to right-click on references and choose "Add reference". Then I should see those references in the register ".NET", right? Is it possible that I can't see them because I use the express version of Visual Studio?
Hi, one of the DLLs come from Expression Blend.
You can also do it in Code Behind (calling VisualStateManager.GoToState or something similar).
Anyway, I'm attaching a project by a link to Rapidshare/Megaupload.
Take the missing DLLs from it:

https://rapidshare.com/files/1754085932/SilverlightOuterGlow.rar
http://www.megaupload.com/?d=8E5L7QXA
http://www.mediafire.com/?2ija4rz1z6n415g
You are a genius!

Thanks a lot for your great help!
10x :-)