Silverlightのオブジェクトを表示するには、XAMLファイルに表示内容を記述する必要があります。
そして、そのXAMLファイルには、少なくとも1つはキャンバスオブジェクトが必要です。
キャンバスオブジェクトは
<Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> </Canvas>
のように記述し、<Canvas>~</Canvas>の間に描画する要素(円、矩形、テキストなどのオブジェクト)を追加していきます。
上記の<Canvas>~</Canvas>はお決まりですので、コピーして使うとよいでしょう。
今回はsample2というフォルダを作成して、前回使用したファイル群をコピーしXAMLファイルだけ入れ替えて使用したいと思います。
オブジェクトの追加方法を練習するために、キャンバスに円を描いてみたいと思います。
まずは円を描くために<Ellipse>を追加します。
XAMLファイルを下記のようにしてください。
<Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Ellipse Height="100" Width="100" Stroke="Black" StrokeThickness="3" Fill="Blue" /> </Canvas>
<Ellipse>タグの要素について説明します。
Heightは円の高さ、Widthは円の幅を表しており、現在は1:1で指定しているので円になります。比率を変えることで楕円を描くこともできます。
Strokeは線の色を表します。
StrokeThicknessは線の太さを表します。
Fillは塗りつぶしの色を表します。
このように、表示するオブジェクトは<Canvas>~</Canvas>に追加するということを覚えておいてください。
今回のサンプルの実行結果はこちらで確認することができます。
今回のサンプルファイルのダウンロードはこちらからどうぞ。
Theme design by Jelle Druyts
Pick a theme: BlogXP business calmBlue Candid Blue dasBlog dasblogger DirectionalRedux Discreet Blog Blue Elegante essence Just Html MadsSimple Mobile Mono Movable Radio Blue Movable Radio Heat nautica022 orangeCream Portal Project84 Project84Grass Slate Sound Waves Tricoleur useit.com Voidclass2 BlogXP business calmBlue Candid Blue dasBlog dasblogger DirectionalRedux Discreet Blog Blue Elegante essence Just Html MadsSimple Mobile Mono Movable Radio Blue Movable Radio Heat nautica022 orangeCream Portal Project84 Project84Grass Slate Sound Waves Tricoleur useit.com Voidclass2
Powered by: newtelligence dasBlog 2.0.7226.0
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2009, HIRO
E-mail