【发布时间】:2011-06-09 13:25:37
【问题描述】:
我的项目中有一张图片。
在解决方案资源管理器中,我创建了一个名为“Resources”的文件夹,并在该文件夹中添加了一张图片。
我想将图像设置为该文件夹中的文件。这是我的 C# 代码
BitmapImage splashScreenImageSource = new BitmapImage();
splashScreenImageSource.BeginInit();
splashScreenImageSource.UriSource = new Uri("world_splash.jpg", UriKind.Relative);
splashScreenImageSource.EndInit();
splashScreenImage.Source = splashScreenImageSource;
当我跑步时,什么也没有发生。
这是我的 XAML 代码
<Window x:Class="Bail.SplashScreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="256" Width="456" Background="#00005555" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterScreen" >
<Grid Width="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Image x:Name="splashScreenImage" Stretch="Fill" Grid.Row="0" />
</Grid>
</Window>
感谢您的所有帮助。 如果您需要查看,这里是 App.xaml
<Application x:Class="Bail.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="SplashScreen.xaml">
<Application.Resources>
</Application.Resources>
</Application>
【问题讨论】:
标签: c# wpf visual-studio-2010 c#-4.0 splash-screen