代码之家  ›  专栏  ›  技术社区  ›  Steven

silverlight网格背景图像

  •  2
  • Steven  · 技术社区  · 15 年前

    如何在c#(代码隐藏)中设置网格的背景图像。

    谢谢 服务提供商

        public ImageSource ImageSourcePin
    {
        set { this.DreamTypeImagePin.Background = value; }
    }
    

    这起作用了,谢谢你的帮助

            public String ImageSourcePin
        {
            set {
                ImageBrush img = new ImageBrush();
                img.ImageSource = (ImageSource)new ImageSourceConverter().ConvertFromString(value); 
                DreamTypeImagePin.Background = img;
            }
        }
    
    2 回复  |  直到 15 年前
        1
  •  4
  •   Prince Ashitaka    15 年前

    ImageBrush img=新建ImageBrush(); 图像源=(ImageSource)新建ImageSourceConverter().ConvertFromString(“图片.jpg"); g、 背景=img;

    HTH公司

        2
  •  11
  •   Callum Rogers    15 年前

    ImageBrush <Grid> </Grid>

    <Grid.Background>
        <ImageBrush ImageSource="Image.jpg"/>
    </Grid.Background>
    

    当然,你可以这样写:

    ImageBrush imgBrush = new ImageBrush();
    imgBrush.ImageSource = new BitmapImage(new Uri(@"folder\img.jpg", UriKind.Relative));
    grid.Background = imgBrush;