我创建一个矩形
public void Set(Rectangle maps, int y, int x) {
Map.Children.Add(maps);
maps.SetValue(Grid.RowProperty, x);
maps.SetValue(Grid.ColumnProperty, y);
}
Run Code Online (Sandbox Code Playgroud)
但如何用"Resources/1.jpg"改变背景?
像这样:
<Rectangle>
<Rectangle.Fill>
<ImageBrush ImageSource="/YourAppName;component/Resources/1.jpg" />
</Rectangle.Fill>
</Rectangle>
Run Code Online (Sandbox Code Playgroud)
再次编辑(对不起)
或者在C#中
maps.Fill = new ImageBrush {
ImageSource = new BitmapImage(new Uri(@"pack://application:,,,/YourAppName;component/Resources/1.jpg", UriKind.Absolute))
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7957 次 |
| 最近记录: |