wpf xaml 编程第一步 以旋转的立方体为代码展示

<Window x:Class="TestWPF_20100611_.Window4" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="3D图形的显示" Height="324" Width="344"> <Window.Resources> <SolidColorBrush x:Key="bg" Color="Red" /> </Window.Resources> <DockPanel> <WrapPanel x:Name="panel" DockPanel.Dock="Top"> <Button Background='{StaticResource bg}' Click='HowdyClicked'>Howdy</Button> <Button Background="{StaticResource bg}">A Second button</Button> <TextBox x:Name="_text1">An editable text box</TextBox> <CheckBox Content='{Binding ElementName=_text1,Path=Text}'/> <Slider Width="75" Minimum="0" Maximum="100" Value="60" /> </WrapPanel> <!--<Rectangle Margin="5"> <Rectangle.Fill> <VisualBrush Visual='{Binding ElementName=panel}' Viewport="0,0,.5,.1" TileMode="Tile" /> </Rectangle.Fill> </Rectangle>--> <Viewport3D> <Viewport3D.Camera> <PerspectiveCamera LookDirection="-.7,-.8,-1" Position="3.8,4,4" FieldOfView="17" UpDirection="0,1,0" /> </Viewport3D.Camera> <ModelVisual3D> <ModelVisual3D.Content> <Model3DGroup> <PointLight Position="3.8,4,4" Color="White" Range="7" ConstantAttenuation="1.0" /> <GeometryModel3D> <GeometryModel3D.Transform> <RotateTransform3D CenterX=".5" CenterY=".5" CenterZ="-.5"> <RotateTransform3D.Rotation> <AxisAngleRotation3D x:Name="rotation" Axis="0,1,0" Angle="0" /> </RotateTransform3D.Rotation> </RotateTransform3D> </GeometryModel3D.Transform> <GeometryModel3D.Geometry> <MeshGeometry3D TextureCoordinates="0,0 1,0 0,-1 1,-1 0,0 1,0 0,-1 0,0" Positions="0,0,0 1,0,0 0,1,0 1,1,0 0,1,-1 1,1,-1 1,1 -1 1,0,-1" TriangleIndices="0,1,2 3,2,1 4,2,3 5,4,3 6,3,1 7,6,1" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial> <DiffuseMaterial.Brush> <VisualBrush Viewport="0,0,.5,.25" TileMode="Tile" Visual="{Binding ElementName=panel}" /> </DiffuseMaterial.Brush> </DiffuseMaterial> </GeometryModel3D.Material> </GeometryModel3D> </Model3DGroup> </ModelVisual3D.Content> </ModelVisual3D> </Viewport3D> </DockPanel> <Window.Triggers> <EventTrigger RoutedEvent="FrameworkElement.Loaded"> <EventTrigger.Actions> <BeginStoryboard> <BeginStoryboard.Storyboard> <Storyboard> <DoubleAnimation From="-25" To="25" Storyboard.TargetName="rotation" Storyboard.TargetProperty="Angle" AutoReverse="True" Duration="0:0:2.5" RepeatBehavior="Forever" /> </Storyboard> </BeginStoryboard.Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </Window.Triggers> </Window>

另外还可以通过定义样式来影响现实:

<Window.Resources> <SolidColorBrush x:Key="bg" Color="Red" /> <Style x:Key="{x:Type Button}" TargetType="{x:Type Button}"> <Setter Property="Background" Value="{StaticResource bg}"/> </Style> </Window.Resources>

最近在看"WPF核心技术",学习WPF编程,之前动力不是很足的,但前天在去长春的火车上听说了它的另一个解释(非计算机程序员说的),

之后觉得太有东西学习了,一看到wpf就开心,心里作用真是大呀,呵呵!

文字的描述就不多敲了。待续.....

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值