如何:创建和使用画布How to: Create and Use a Canvas
03/30/2017
本文内容
此示例演示如何创建和使用的实例 Canvas 。This example shows how to create and use an instance of Canvas.
示例Example
The following example explicitly positions two TextBlock elements by using the SetTop and SetLeft methods of Canvas. 该示例还将 Background 的颜色分配 LightSteelBlue 给 Canvas 。The example also assigns a Background color of LightSteelBlue to the Canvas.
备注
当你使用 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML) 来放置 TextBlock 元素时,请使用 Top 和 Left 属性。When you use 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML) to position TextBlock elements, use the Top and Left properties.
private void CreateAndShowMainWindow()
{
// Create the application's main window
mainWindow = new Window();
// Create a canvas sized to fill the window
Canvas myCanvas &#