Welcome to MSDN Blogs Sign in | Join | Help

Creating a simple style with one trigger

This article describes how to create a simple style with one trigger in Microsoft Expression Interactive Designer. We will create a blue rectangle which becomes red when the mouse is over it.

Step 1 - Create a rectangle

Draw a rectangle using the "Rectangle" tool from the Tools palette
Click on the "Selection" tool on the tools palette

Step 2 - Clear the Fill property

EID by default sets a Fill to your rectangle which would override our Style settings, so we need to delete that property (if you switch to the xaml view, you will notice that there is a Fill attribute specified for the rectangle):
In the Properties palette, Click on the Fill property and Select "Clear/Default" -
this should clear the property

Step 3 - Create a Style for the rectangle

In the timeline, right click on your rectangle->Edit Style->Create Empty Style (usually you should be able to do this in the scene, but now, because the Fill property is not set, the rectangle may not selectable in the scene - known issue)

Click "Ok" in the "Create Style Resource" dialog

Step 4 - Set a default Fill for the rectangle inside the Style

Bring up the "Timeline" palette - note that we are currently editing the style (the node displayed should be "Style"). In order to get the mouse events at runtime, our rectangle will need a Fill; so we will set a Fill in the Style.

In the Appearance palette, set the Fill to "blue" (because we are in the Style editing mode, this will create a Setter inside the style)

Step 5 - Add a Trigger for the IsMouseOver

Click on the "Create New State" button; a new tab called "[No Triggers]" is displayed in the timeline; Click on it
Bring up the "Timeline Properties" palette (using the "View" menu)
Create a new trigger: Click on the "Add" button in the "Timeline Properties" to add a new trigger; in the first textbox type "IsMouseOver" and "true" in the second one; now the tab is called "IsMouseOver"
Ensure that the "IsMouseOver" tab is selected and change the "Fill" color in the "Appearance" palette to your desired color (e.g. "red")
Click the "Return Scope To Root" button (in the Timeline palette) to end the style editing mode

The final xaml

The final xaml looks like:
	<Grid.Resources>
		<Storyboard x:Key="OnLoaded"/>
		<Style x:Key="RectangleStyle1" TargetType="{x:Type Rectangle}">
			<Setter Property="Fill" Value="sc#1, 0, 0, 1"/>
			<Style.Triggers>
				<MultiTrigger>
					<MultiTrigger.Conditions>
						<Condition Property="IsMouseOver" Value="True"/>
					</MultiTrigger.Conditions>
					<Setter Property="Fill" Value="sc#1, 1, 0, 0"/>
				</MultiTrigger>
			</Style.Triggers>
		</Style>
	</Grid.Resources>
<Rectangle Stroke="#FF000000" Style="{DynamicResource RectangleStyle1}"
	Width="Auto" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
	MinWidth="0" MinHeight="0" Margin="128,99,183,202" x:Name="Rectangle"
	RenderTransformOrigin="0.5,0.5"/>
Published Thursday, February 16, 2006 2:11 AM by adrianvinca

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Team posts on Styles and Templates

Tuesday, February 21, 2006 6:06 PM by The Expression Designers: Graphic, Interactive, Web
Check out a couple of personal blog postings from some members of the Expression team.Adrian Vinca [1]...

# and now with an ellipse...

Wednesday, February 22, 2006 4:36 PM by jmwatte
And then I took your procedure and did the same thing with an ellipse...but it don't work. I can remove the fill but when I'm in the style and want to apply the fill... nothing...

Normal or not ?

# re: Creating a simple style with one trigger

Wednesday, February 22, 2006 8:58 PM by adrianvinca
I've just tried with an ellipse and it worked.

Please make sure that the Fill property was removed by switching to the xaml view (inside <Rectangle ... /> you shouldn't see any Fill="...").

If this doesn't fix your problem, could you please describe me exactly the steps you do?

Thanks,
- Adrian

# re: Creating a simple style with one trigger

Thursday, February 23, 2006 6:30 AM by jmwatte
Found the problem...

1. make an ellipse(with fill)
2. clear the fill in the appearance tab(the red line box)
3. go to properties and you cann't "clear/default" it...

So, I have to skip the 2nd step to make it work...

# re: Creating a simple style with one trigger

Thursday, February 23, 2006 3:45 PM by adrianvinca
Hi,

It looks like you are running into a bug of Expression Interactive Designer. When you set the "Fill" to "No Color" in the properies palette generates in the xaml Fill="x:Null" - which still overrides the values from the style. The problem is that "Clear/Default" menu items become disable at that point. (I've just filed the bug, but I'm afraid it won't get fixed for the next version).

So, to avoid this problem, don't set the Fill to "No Color" in the Appearance palette. Just use the "Clear/default" option for the "Fill" property in the properties palette.

I am sorry about the confusion and thanks for pointing out this issue.

- Adrian

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker