Silverlight newbie here, so I apologize if this question isn’t even worded correctly.
I am playing around with a richtextbox and storyboard animations. Basically, on mouseenter animate to 100px, on mouseleave animate to 0px.
This is fairly basic, but what I can’t figure out is how to see if it is in the minimize or maximize state.
Here is the XAML:
<UserControl x:Class="AnotherTester.MainPage"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.Resources>
<Storyboard x:Name="Shrink">
<DoubleAnimation Storyboard.TargetName="textBox"
Storyboard.TargetProperty="Height"
From="100" To="0" Duration="00:00:00.5" />
</Storyboard>
<Storyboard x:Name="Grow">
<DoubleAnimation Storyboard.TargetName="textBox"
Storyboard.TargetProperty="Height"
From="0" To="100" Duration="00:00:00.5" />
</Storyboard>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Width="100">
<Rectangle x:Name="rectangle" Fill="#FF0202F9" Height="20" Stroke="Black" Width="100" MouseEnter="rectangle_MouseEnter" MouseLeave="rectangle_MouseLeave" />
<RichTextBox x:Name="textBox" Height="100">
<Paragraph><Run Text="This"/></Paragraph>
<Paragraph><Run Text="is"/></Paragraph>
<Paragraph><Run Text="some"/></Paragraph>
<Paragraph><Run Text="awesome"/></Paragraph>
<Paragraph><Run Text="text"/></Paragraph>
</RichTextBox>
</StackPanel>
</Grid>
And the code Behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace AnotherTester
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
private void rectangle_MouseEnter(object sender, MouseEventArgs e)
{
Grow.Begin();
}
private void rectangle_MouseLeave(object sender, MouseEventArgs e)
{
Shrink.Begin();
}
}
}
EDIT:
Ok, I just changed the starting height of the control to 0px, which gave me the effect I was looking for (all collapsed boxes until we mouse over them), but I would still like to know how to check against things like this..
on solution would be to use the storyboards completed event to let you set the state.
example