小编sok*_*vic的帖子

如何设置WPF窗口的背景?

我有一个简单的WPF窗口.我打算将它的背景设置为我作为嵌入式资源项目添加的图像之一.这是我试过的:

<Window x:Class="A_Boggle.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="A-Boggle" Height="300" Width="625" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Name="Game">
<Window.Background>
    <ImageBrush ImageSource="background.jpg"></ImageBrush>
</Window.Background>
<Grid>
</Grid>
Run Code Online (Sandbox Code Playgroud)

但有了这个,我总是得到这个:"错误1文件splash.jpg不是项目的一部分,或者它的'Build Action'属性没有设置为'Resource'."

有任何想法吗?

wpf background

30
推荐指数
1
解决办法
5万
查看次数

标签 统计

background ×1

wpf ×1