控件有默认样式,但是有时候默认样式并不够用,就需要美化。

1、常用的方法是美术出图,直接贴图进去,效果又好又简单(对程序来说)。

用图片有三种方式:设置控件背景图片、设置控件内容为图片和直接使用图片做控件三种。

【WPF】2、美化控件
<Window x:Class="战五渣之环游世界.WPF.Window1"
        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:战五渣之环游世界.WPF"
        mc:Ignorable="d"
        Title="Window1" Height="450" Width="800">
    <!--方案一,设置控件的背景为图片-->
    <Window.Background>
        <ImageBrush ImageSource="/images/mainbg.jpg"></ImageBrush>
    </Window.Background>
    <Grid>
        <Button>
            <!--方案二,设置控件的内容为图片,这里不能使用背景图片,因为按钮默认具有鼠标经过样式-->
            <Image Source="/images/mainbg.jpg"></Image>
        </Button>
    </Grid>
</Window>
贴图美化

相关文章:

  • 2022-12-23
  • 2022-01-26
  • 2021-10-24
  • 2021-10-03
  • 2022-12-23
  • 2021-12-22
  • 2021-10-15
猜你喜欢
  • 2021-09-04
  • 2021-12-20
  • 2021-12-11
  • 2021-11-29
  • 2021-07-27
  • 2021-01-29
  • 2022-12-23
相关资源
相似解决方案