代码分享
WPF界面背景图片设置
<Window.Background>
<ImageBrush ImageSource="/Resources/Main/bg.png"/>
</Window.Background>
Grid界面背景设置
<Window.Background>
<Grid>
<Grid.Background>
<LinearGradientBrush StartPoint="0,1" EndPoint="1,1" Opacity="0.4">
<GradientStop Offset="0" Color="#212842"/>
<GradientStop Offset="1" Color="#353655"/>
</LinearGradientBrush>
</Grid.Background>
</Grid>
下面附上所有代码
<Window x:Class="WpfApp1.MainWindow"
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:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Background>
<ImageBrush ImageSource="/Resource/bg.png"/>
</Window.Background>
<Grid>
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="125"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="860"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="0" Margin="20,0,0,0">
<Image x:Name="imgLogo" Source="Resources/hlogo.png" Height="120" Width="120"></Image>
<StackPanel VerticalAlignment="Center" Margin="20,0,0,0">
<TextBlock Foreground="White" FontSize="42" >XXXX管理系统</TextBlock>
<TextBlock Foreground="#FFA8A2A2" FontSize="23">XXXXXXX</TextBlock>
</StackPanel>
</StackPanel>
</Grid>
</Grid>
</Grid>
</Window>