I took an session on WPF for awareness on WPF and silverlight
Here is the presentation on WPF basics and the Demo code which i did along with.
The demo is about animation (rotation), binding (to a static class or to another control)…
here is a snapshot
here is the WPF code
1: <Window x:Class="WpfApplication1.Window1"
2: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4: xmlns:g="clr-namespace:System.Globalization;assembly=mscorlib"
5: Title="Window1" Height="800" Width="900">
6: <Canvas Height="800" Width="900">
7: <Canvas x:Name="mainCanvas" Width="300" Height="300" Canvas.Top="0" Canvas.Left="100">
8:
9: <Canvas.Background>
10: <LinearGradientBrush>
11: <GradientStop Offset=".6" Color="Red"></GradientStop>
12: <GradientStop Offset=".2" Color="White"></GradientStop>
13: <GradientStop Offset=".2" Color="Yellow"></GradientStop>
14: </LinearGradientBrush>
15: </Canvas.Background>
16: <Ellipse Height="200" Width="100" Fill="Red">
17: <Ellipse.RenderTransform>
18: <RotateTransform x:Name="ellipseScale" Angle="0"></RotateTransform>
19: </Ellipse.RenderTransform>
20: </Ellipse>
21: <Button Content="OK" Canvas.Top="50" Canvas.Left="60">
22: <Button.Triggers>
23: <EventTrigger RoutedEvent="Button.Click">
24: <BeginStoryboard>
25: <Storyboard Storyboard.TargetName="ellipseScale" Storyboard.TargetProperty="Angle">
26: <DoubleAnimation From="0" To="360" Duration="0:0:2"></DoubleAnimation>
27: </Storyboard>
28:
29: </BeginStoryboard>
30: </EventTrigger>
31: </Button.Triggers>
32: </Button>
33: <ListBox Height="200" Width="200" x:Name="lst" Canvas.Top="0" Canvas.Left="150"
34: ItemsSource="{Binding Source={x:Static g:DateTimeFormatInfo.CurrentInfo}, Path=DayNames }">
35:
36: </ListBox>
37: <MediaElement Canvas.Top="150" Canvas.Left="150" Height="200" Width="200" Source="FluidWater1.wmv"></MediaElement>
38: </Canvas>
39: <TextBlock Text="working"></TextBlock>
40: <StackPanel Width="400" Height="300" Canvas.Top="300" Canvas.Left="100" Opacity=".5" >
41: <StackPanel.Background>
42: <VisualBrush Visual="{Binding ElementName=mainCanvas}">
43: <VisualBrush.RelativeTransform>
44: <TransformGroup>
45: <ScaleTransform ScaleX="1" ScaleY="-1"></ScaleTransform>
46: <TranslateTransform Y="1" ></TranslateTransform>
47: </TransformGroup>
48: </VisualBrush.RelativeTransform>
49: </VisualBrush>
50: </StackPanel.Background>
51: </StackPanel>
52: </Canvas>
53: </Window>
I will be blogging more advanced stuff in nextblogs..
Happy WPF ing
Technorati Tags: WPF
No comments:
Post a Comment