0
Q
WPF:平鋪圖像
A
回答
1
這是我從MSDN借用的示例Rectangle。
DrawingBrush myBrush = new DrawingBrush();
GeometryDrawing backgroundSquare =
new GeometryDrawing(
Brushes.White,
null,
new RectangleGeometry(new Rect(0, 0, 100, 100)));
GeometryGroup aGeometryGroup = new GeometryGroup();
aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, 50, 50)));
aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(50, 50, 50, 50)));
LinearGradientBrush checkerBrush = new LinearGradientBrush();
checkerBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0));
checkerBrush.GradientStops.Add(new GradientStop(Colors.Gray, 1.0));
GeometryDrawing checkers = new GeometryDrawing(checkerBrush, null, aGeometryGroup);
DrawingGroup checkersDrawingGroup = new DrawingGroup();
checkersDrawingGroup.Children.Add(backgroundSquare);
checkersDrawingGroup.Children.Add(checkers);
myBrush.Drawing = checkersDrawingGroup;
myBrush.Viewport = new Rect(0, 0, 0.25, 0.25);
myBrush.TileMode = TileMode.Tile;
exampleRectangle.Fill = myBrush;
它演示瞭如何平鋪一個矩形。這裏是MSDN的鏈接: WPF Brush Overview - MSDN
1
如果你正在繪製一個DrawingBrush
你的形象,你可以將屬性TileMode
設置爲TileMode.Tile
。假設我已經正確地理解了你的問題,它會做你想做的。
相關問題
- 1. iphone平鋪圖像
- 2. Rapheal js圖像平鋪
- 3. 平鋪UIVIew中的圖像
- 4. 圖像平鋪註冊
- 5. 如何平鋪圖像
- 6. WPF中ListView的平鋪視圖
- 7. LibTIFF.NET將平鋪的OJPEG轉換爲單個平鋪圖像
- 8. 平鋪背景圖像不能平鋪在整個頁面上
- 9. WPF和窗口平鋪
- 10. WPF平鋪背景錯位
- 11. 如何在WPF中平鋪和疊加圖像?
- 12. LibGDX:從平鋪到平鋪渲染平鋪地圖
- 13. 平鋪地圖
- 14. 平鋪圖案
- 15. 顯示平鋪和重疊的圖像
- 16. 打印圖像在網頁上平鋪
- 17. 查看大量的平鋪圖像
- 18. iTextSharp:表格中的平鋪圖像
- 19. 使用ImageMagick重複或「平鋪」圖像
- 20. 在ie8中平鋪兩個圖像
- 21. 縮放圖像以適合平鋪
- 22. 我們如何平鋪矢量圖像?
- 23. WP8一些遠程圖像次平鋪
- 24. 的Android - 平鋪圖像按鈕
- 25. 平鋪小圖像尺寸指南?
- 26. 如何用QT繪製平鋪圖像
- 27. OpenLayers中的平鋪背景圖像
- 28. 爲PhotoScroller編程圖像平鋪
- 29. 對齊圖像垂直平鋪在
- 30. 平鋪圖像庫中的Java
謝謝你的回覆。現在,我得到以下XAML代碼: <圖像刷視口= 「0,0,0.25,0.25」 TILEMODE = 「瓷磚」 的ImageSource = 「Background1.png」/> 矩形。填充> 這可以平鋪圖片;但是當我調整Rectangle的大小時,「平鋪圖片」就會被拉伸。但是,我希望它們重複(如HTML網頁上的背景圖像)。 –
alxppp
2010-08-24 10:59:47
Found the solution: –
alxppp
2010-08-24 13:51:51
對不起,我不能回覆你的評論,我只是醒了:P我很高興你把它全部排序。 :d – 2010-08-25 05:44:02