惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Blog — PlanetScale
Blog — PlanetScale
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
L
LangChain Blog
F
Fortinet All Blogs
C
Check Point Blog
Google DeepMind News
Google DeepMind News
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
J
Java Code Geeks
月光博客
月光博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
宝玉的分享
宝玉的分享
Jina AI
Jina AI

博客园 - 颜昌钢

怎样做好一个项目经理? ICollection 与 IList 区别 oracle 数据库跨库查询方法 SetTimeOut 与 SetInterval 区别 - 颜昌钢 内存释放 机制 remoting 学习整理 GC 资源 回收 WPF中代码画箭头 方法参数 Ref 与 引用类型 DataTrigger 以及 EnterActions 和ExitActions 学习笔记 - 颜昌钢 WPF xaml文件中使用大括号{} - 颜昌钢 - 博客园 WPF下的地图解决方案 关于WPF的Binding 的 ConverterParameter 参数的动态设置 关于 项目 投标相关文档 服务器计时器、Windows 计时器和线程计时器 wpf小控件 集合 仪表盘等 wpf button 事件的触发顺序 - 颜昌钢 c# 插件 体系 一个类似于 splittercontainer 控件的控件
wpf windows 放大缩小 疑问?? - 颜昌钢
颜昌钢 · 2010-04-05 · via 博客园 - 颜昌钢

某一天,有位兄弟问起,怎么在wpf 中做窗体的旋转放大,缩小的效果,当自己写了如下代码后,才发觉,很是怪异。。

<Window x:Class="WpfWindowTransform.Window2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window2" Height="300" Width="300"  x:Name="Windows2" Background="Yellow" RenderTransformOrigin="0.5,0.5"
        WindowStartupLocation="CenterScreen"  ResizeMode="NoResize" ShowInTaskbar="False">
    <Window.RenderTransform>
        <TransformGroup>
            <ScaleTransform ScaleX="1" ScaleY="1"/>
            <SkewTransform AngleX="0" AngleY="0"/>
            <RotateTransform Angle="0"/>
            <TranslateTransform X="0" Y="0"/>
        </TransformGroup>
    </Window.RenderTransform>
    <Window.Resources>
        <Storyboard x:Key="ScaleXStoryboard">
            <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" BeginTime="00:00:00" Storyboard.TargetName="Windows2" 
                                                   Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
                <SplineDoubleKeyFrame KeyTime="00:00:03" Value="360"></SplineDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Windows2"
                                                   Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                <SplineDoubleKeyFrame KeyTime="00:00:03" Value="0.1"></SplineDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Windows2"
                                                   Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                <SplineDoubleKeyFrame KeyTime="00:00:03" Value="0.1"></SplineDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </Window.Resources>
    <Window.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource ScaleXStoryboard}"> 
            </BeginStoryboard>
        </EventTrigger>
    </Window.Triggers>
   
    <Grid Background="Red" Width="200" Height="200">
       
    </Grid>
</Window>

执行这个程序,可以看出,最终旋转效果,并非包括window的外面的部分,既 window上的标题栏,按钮等,并不会跟着旋转。。旋转的只是window窗体的内容部分!。。。。。。。。。。

当然,如果加上 WindowStyle="None" AllowsTransparency="True"  这句话,也就没有了后面的黑色背景,但是,也是没了窗体的关闭等等按钮了。。。。