WPF 窗口图标与背景

1

图标Icon

Icon="Images/icon.jpg"

背景图Background

<Window.Background>
    <ImageBrush ImageSource="Images/background.jpg"></ImageBrush>
</Window.Background>

完整代码:

<Window x:Class="WpfDemo.WindowIconAndBackground.WindowIconAndBackgroundDemo"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfDemo.WindowIconAndBackground"
        mc:Ignorable="d" Icon="Images/icon.jpg"
        Title="WindowIconAndBackgroundDemo" Height="350" Width="600">
    <Window.Background>
        <ImageBrush ImageSource="Images/background.jpg"></ImageBrush>
    </Window.Background>
    <Grid>
        
    </Grid>
</Window>

示例代码

https://github.com/zLulus/NotePractice/tree/dev3/WPF/WpfDemo/WindowIconAndBackground

原文地址:https://www.cnblogs.com/Lulus/p/8158376.html