C# (WinRT): 図形を描画

MyDrawPage

xaml: MyDrawPage.xaml

<Page
    x:Class="Snippets.MyDrawPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Snippets"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid x:Name="grid" Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

    </Grid>
</Page>

C#: MyDrawPage.xaml.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI;
using Windows.UI.Xaml.Shapes;

namespace Snippets
{
    public sealed partial class MyDrawPage : Page
    {
        public MyDrawPage()
        {
            this.InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine(Window.Current.Bounds.Width);

            Canvas canvas = new Canvas();
            canvas.Background = new SolidColorBrush(Color.FromArgb(255,255,255,255));
            
            // draw grid
            Color cyan = Color.FromArgb(255, 100, 100, 255);
            SolidColorBrush lineBrush = new SolidColorBrush();
            lineBrush.Color = cyan;
            for (int x = 50; x < Window.Current.Bounds.Width; x += 50)
            {
                Line line = new Line() { X1 = x, Y1 = 0, X2 = x, Y2 = Window.Current.Bounds.Height };
                line.StrokeThickness = 1;
                line.Stroke = lineBrush;
                canvas.Children.Add(line);
            }
            for (int y = 50; y < Window.Current.Bounds.Height; y += 50)
            {
                Line line = new Line() { X1 = 0, Y1 = y, X2 = Window.Current.Bounds.Width, Y2 = y };
                line.StrokeThickness = 1;
                line.Stroke = lineBrush;
                canvas.Children.Add(line);
            }

            // draw rectangle
            Rectangle rect = new Rectangle();
            rect.Fill = new SolidColorBrush(Color.FromArgb(255,255,0,0));
            rect.Width = 200;
            rect.Height = 200;
            Canvas.SetLeft(rect, 300);
            Canvas.SetTop(rect, 100);
            canvas.Children.Add(rect);

            // draw circle
            Ellipse circle = new Ellipse();
            circle.Fill = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0));
            circle.Stroke = new SolidColorBrush(Color.FromArgb(255,255,0,0));
            circle.StrokeThickness = 10;
            circle.Width = 150;
            circle.Height = 200;
            Canvas.SetTop(circle, 300);
            Canvas.SetLeft(circle, 600);
            canvas.Children.Add(circle);

            // draw triangle
            Polygon triangle = new Polygon();
            triangle.Fill = new SolidColorBrush(Color.FromArgb(255, 255, 255, 0));
            PointCollection points = new PointCollection();
            points.Add(new Point(50, 300));
            points.Add(new Point(250, 500));
            points.Add(new Point(50, 400));
            triangle.Points = points;
            canvas.Children.Add(triangle);

            // draw text
            TextBlock textBlock = new TextBlock();
            textBlock.Text = "Hogehoge";
            textBlock.FontSize = 80;
            textBlock.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
            Canvas.SetLeft(textBlock, 800);
            Canvas.SetTop(textBlock, 200);
            canvas.Children.Add(textBlock);

            this.grid.Children.Add(canvas);
        }
    }
}

Microsoft の描画についてのページがよくまとまっています。