32
A
回答
30
你忘了Background属性。画笔应该是一个ImageBrush,其ImageSource可以设置为图像路径。
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/path/to/image.png" Stretch="UniformToFill"/>
</Grid.Background>
<...>
</Grid>
19
我有我的图像在一个单独的类库(“MyClassLibrary”),他们被放置在文件夹“图像”。在这个例子中,我使用“myImage.jpg”作为背景图片。
ImageBrush myBrush = new ImageBrush();
Image image = new Image();
image.Source = new BitmapImage(
new Uri(
"pack://application:,,,/MyClassLibrary;component/Images/myImage.jpg"));
myBrush.ImageSource = image.Source;
Grid grid = new Grid();
grid.Background = myBrush;
+0
自从你创建'Image'没有意义'不要用它来做任何事情。你可以直接在'ImageBrush'上设置'ImageSource'。 – devios1 2016-11-25 18:13:45
62
所有这一切都可以很容易地在XAML由网格
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/MyProject;component/Images/bg.png"/>
</Grid.Background>
</Grid>
留给你做的,是添加一个文件夹来解决所谓的“形象”,并加入以下代码来达到的将现有文件添加到新的'Images'文件夹中,在这种情况下称为'bg.png'
0
为了避免路径问题,您可以简单地尝试此操作,只需在图像文件夹中保留背景图像并添加此代码
<Grid>
<Grid.Background>
<ImageBrush Stretch="Fill" ImageSource="..\Images\background.jpg"
AlignmentY="Top" AlignmentX="Center"/>
</Grid.Background>
</Grid>
相关问题
- 1. J2ME在背景图像上设置textfield
- 2. 如何在wpf中设置网格列的背景颜色?
- 3. 从Android上的图像设置背景
- 4. 在WPF中设置我的图像背景
- 5. 在WPF页面中添加网格背景图像
- 6. 使用样式设置WPF控件背景图像?
- 7. 在Java中设置背景图像
- 8. 设置背景图像alertdialog
- 9. UITableViewCell背景图像设置
- 10. 设置JWindow背景图像
- 11. angularjs设置背景图像
- 12. WPF使用网格作为背景
- 13. 在网格视图中按项目位置设置背景
- 14. 在背景图像上设置图像的问题android
- 15. 使用Swing在JFrame上设置背景图像
- 16. 如何在C#WPF代码中更改\设置按钮的背景图像?
- 17. 如何使用Interface Builder在视图中设置背景图像
- 18. 从c#代码设置全景视图的WP7背景图像
- 19. 设置背景图像在背景中褪色
- 20. 设置在Android中使用ListAdapter创建ListItem的背景图像
- 21. 在c中设置一个堆叠面板的背景图像#
- 22. 如何在另一个背景图像背后设置背景?
- 23. 如何设置网格的背景?
- 24. iPad3上的视网膜显示使用css设置背景图像
- 25. 如何在设计库的FAB背景上设置fabSize图像?
- 26. 以编程方式在背景图像中设置背景图像
- 27. 用javascript设置背景图像
- 28. 背景图片上的背景图像
- 29. 如何使用背景图像设置QTableWidget左上角?
- 30. JFrame背景图背景图像设置时,其他按钮不显示在图像上的图像?
可以告诉我这个 – Shashank 2010-06-23 10:41:56
的确切语法@SHASHANK:语法是这样的:' ' –
Amsakanna
2010-06-23 10:49:19