wpf 控件添加背景图片

方法一,xaml中:

<控件>   
    <控件.Background>
        <ImageBrush ImageSource="/WpfApplication1;component/Images/xxx.jpg"/>
    </控件.Background>
</控件>      

 

方法二,cs中:

ImageBrush bg = new ImageBrush();
bg.ImageSource = new BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute));
this.Background = bg;

 

posted @ 2019-03-27 19:05  microsoftzhcn  阅读(5516)  评论(0编辑  收藏  举报