【问题标题】:How to display wpf Splash screen inside main window?如何在主窗口内显示 wpf 启动画面?
【发布时间】:2010-07-26 09:50:31
【问题描述】:

WPF 启动画面显示为图像而不是窗口...我的意思是...看起来首先出现图像...然后...我的窗口(我的意思是顶部有条形的窗口)出现in...如何在主窗口中显示图像

【问题讨论】:

  • 在创建和初始化主窗口时,启动屏幕用于显示某些内容。为什么在显示主窗口后会显示启动画面?为什么不直接截取主窗口的屏幕截图并将其用作启动屏幕?

标签: wpf uiview splash-screen


【解决方案1】:

试试这个

<Window x:Class="WpfApplication43.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="600" Width="800" AllowsTransparency="True" WindowStyle="None" Background="{x:Null}" HorizontalAlignment="Center" VerticalAlignment="Center" WindowStartupLocation="CenterScreen">
<Window.Resources>
    <Storyboard x:Key="OnLoaded1">
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="splashGrid" Storyboard.TargetProperty="(UIElement.Opacity)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
            <SplineDoubleKeyFrame KeyTime="00:00:03" Value="1"/>
            <SplineDoubleKeyFrame KeyTime="00:00:04" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.Opacity)">
            <SplineDoubleKeyFrame KeyTime="00:00:03.6000000" Value="0"/>
            <SplineDoubleKeyFrame KeyTime="00:00:04.3000000" Value="1"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</Window.Resources>
<Window.Triggers>
    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
        <BeginStoryboard Storyboard="{StaticResource OnLoaded1}"/>
    </EventTrigger>
</Window.Triggers>
    <Grid>
        <Grid x:Name="LayoutRoot" Opacity="0" Background="#FF180A0A"/>
        <Grid RenderTransformOrigin="0.5,0.5" Width="400" Height="300"
          x:Name="splashGrid"
          Opacity="0"
              HorizontalAlignment="Center" 
              VerticalAlignment="Center"
          Margin="0,0,0,0" >
            <Border BorderBrush="Black" BorderThickness="0" CornerRadius="10" Background="#FFAD6868">
                <Grid Margin="5">
                    <Image Margin="0" Source="The_Midnight_Sun_by_Isilmetriel.jpg" Stretch="Fill"/>
                </Grid>
            </Border>
        </Grid>
    </Grid>

【讨论】:

  • 这是 mainwindow.xaml 吗?
  • 启动网格位于主窗口内,3 或 4 秒后其可见性将变为 0
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-05-30
  • 1970-01-01
  • 2019-08-22
  • 1970-01-01
  • 2015-09-25
  • 2010-10-28
  • 2015-06-28
相关资源
最近更新 更多