• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1321
  • Last Modified:

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)
0
innovasoft
Asked:
innovasoft
  • 7
  • 5
1 Solution
 
saraganiCommented:
      <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.
0
 
saraganiCommented:
Hi, did you find my answer useful?
0
 
innovasoftAuthor Commented:
hi

thanks a lot for your answer. I couldn't test it yet. I will this evening and let you know
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
innovasoftAuthor Commented:
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
0
 
saraganiCommented:
I would put my guess on visual state manager.

If you can't get your hands and your legs from it, then post back
0
 
saraganiCommented:
<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



With 1 second transition. You can easily change it to 0 seconds and it will change immediately.
0
 
innovasoftAuthor Commented:
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)

0
 
saraganiCommented:
Hi, I forgot to mention that you need to add reference to
System.windows.interactivity
And
Microsoft.expression.interactions. (or something like that)
0
 
innovasoftAuthor Commented:
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?
0
 
saraganiCommented:
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
0
 
innovasoftAuthor Commented:
You are a genius!

Thanks a lot for your great help!
0
 
saraganiCommented:
10x :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now