如何在主窗口中显示wpf启动画面?

发布于 2024-09-11 13:30:01 字数 89 浏览 2 评论 0原文

WPF 启动屏幕显示为图像而不是窗口...我的意思是...看起来首先出现图像..然后...我的窗口(我的意思是顶部有一个栏的窗口)出现.. .如何在主窗口内显示图像

WPF Splash screen getting displayed just as an image not as a window...i mean ...it looks like first an image comes..then...my window(i mean window with a bar at top) comes in...How do I display image inside my main window

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

兲鉂ぱ嘚淚 2024-09-18 13:30:01

试试这个

<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>

just try this

<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>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文