WPF: Designer and Developer
初次尝试,用Expression Blend设计动画,然后在VS 2008中通过编码将动画指派给需要它的控件,感觉不错。
WPF is interesting! I'm a desinger and developer!!
OutlookBar.xml:
OutlookBar.xaml.cs
无需更多的语言了,又O了。
WPF is interesting! I'm a desinger and developer!!
OutlookBar.xml:
<UserControl x:Class="KingUCLs.OutlookBar"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<UserControl.Resources>
<Storyboard x:Key="Storyboard1">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0.5"/>
<SplineDoubleKeyFrame KeyTime="00:00:02" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<Grid x:Name="gridMain">
<StackPanel x:Name="stackPanel1">
</StackPanel>
</Grid>
</UserControl>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<UserControl.Resources>
<Storyboard x:Key="Storyboard1">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0.5"/>
<SplineDoubleKeyFrame KeyTime="00:00:02" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<Grid x:Name="gridMain">
<StackPanel x:Name="stackPanel1">
</StackPanel>
</Grid>
</UserControl>
OutlookBar.xaml.cs
public partial class OutlookBar : UserControl
{
private Storyboard _sButtonMouseEnter = null;
public OutlookBar()
{
InitializeComponent();
Button btnAdd = new Button();
btnAdd.Content = "Add";
btnAdd.Name = "btnAdd";
this.RegisterName(btnAdd.Name, btnAdd);
Button btnDelete = new Button();
btnDelete.Content = "Delete";
btnDelete.Name = "btnDelete";
this.RegisterName(btnDelete.Name, btnDelete);
stackPanel1.Children.Add(btnAdd);
stackPanel1.Children.Add(btnDelete);
_sButtonMouseEnter = (Storyboard)this.FindResource("Storyboard1");
btnAdd.MouseEnter += new MouseEventHandler(onButtonMouseEnter);
btnDelete.MouseEnter += new MouseEventHandler(onButtonMouseEnter);
}
public void onButtonMouseEnter(object sender, RoutedEventArgs e)
{
Storyboard.SetTargetName(_sButtonMouseEnter, ((Button)sender).Name);
_sButtonMouseEnter.Begin((Button)sender);
}
}
}
{
private Storyboard _sButtonMouseEnter = null;
public OutlookBar()
{
InitializeComponent();
Button btnAdd = new Button();
btnAdd.Content = "Add";
btnAdd.Name = "btnAdd";
this.RegisterName(btnAdd.Name, btnAdd);
Button btnDelete = new Button();
btnDelete.Content = "Delete";
btnDelete.Name = "btnDelete";
this.RegisterName(btnDelete.Name, btnDelete);
stackPanel1.Children.Add(btnAdd);
stackPanel1.Children.Add(btnDelete);
_sButtonMouseEnter = (Storyboard)this.FindResource("Storyboard1");
btnAdd.MouseEnter += new MouseEventHandler(onButtonMouseEnter);
btnDelete.MouseEnter += new MouseEventHandler(onButtonMouseEnter);
}
public void onButtonMouseEnter(object sender, RoutedEventArgs e)
{
Storyboard.SetTargetName(_sButtonMouseEnter, ((Button)sender).Name);
_sButtonMouseEnter.Begin((Button)sender);
}
}
}
无需更多的语言了,又O了。