wpf 控件添加背景图片

方法一,xaml中:html

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

 

方法二,cs中:this

ImageBrush bg = new ImageBrush();
bg.ImageSource = new BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute));
this.Background = bg;
相关文章
相关标签/搜索