wpf windows 放大縮小 疑問??

來源:互聯網
上載者:User

某一天,有位兄弟問起,怎麼在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"  這句話,也就沒有了後面的黑色背景,但是,也是沒了表單的關閉等等按鈕了。。。。

 

 

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.