今回は PowerBoots で TextBlock を使用する方法について説明します。
PowerBoots の概要とインストールについては [PowerBoots] PowerBootsをインストールするを参照ください。
PowerBoots PowerBootの基本使用方法
PowerBootsでWPFウィンドウを作成するには
Boots { }
のように記述します。
これはコントロールが配置されていない、Windowのみを表します。
Windowに配置するコントロールは Boots{ } の { ~ } の間に記述します。
TextBlockを使用する
TextBlockはWPFアプリケーションで文字を出力する基本的なコントロールです。
PowerBootsでTextBlockを使用するための、基本的な書き方は
Boots { TextBlock -Text ”表示する文字列”}
です。-Textパラメータの後ろに、表示する文字列を記述します。(赤字の部分を書き換えます)
こうして作成した PowerBootsアプリは下の図のようになります。
次に表示する文字列を改行して2行表示してみましょう。
PowerShellでは改行は’`nで表すことができるので
Boots { TextBlock -Text "Hello PowerBoots!!`nHIRO" }
のようになります。
次にフォントを変えてみましょう。
フォントファミリは-FontFamilyパラメータ、フォントサイズは-FontSizeパラメータを使用します。
Boots { TextBlock -Text "Hello PowerBoots!!`nHIRO" -FontFamily Impact -FontSize 30 }
その他のパラメータ
TextBlockでは先ほど紹介した以外にも多くのプロパティを使用することができます。
すべての使用方法は紹介できないので、使用可能なプロパティ一覧を下記に示します。
下記プロパティを使用する場合は、プロパティ名の前に-(ハイフン)を付加して、PowerShellコマンドレットのパラメータと同じ要領で使用してください。
かっこいいアプリができたときには、是非お知らせください!!
| プロパティ | 定義 |
|---|---|
| ActualHeight | System.Double ActualHeight {get;} |
| ActualWidth | System.Double ActualWidth {get;} |
| AllowDrop | System.Boolean AllowDrop {get;set;} |
| Background | System.Windows.Media.Brush Background {get;set;} |
| BaselineOffset | System.Double BaselineOffset {get;set;} |
| BindingGroup | System.Windows.Data.BindingGroup BindingGroup {get;set;} |
| BitmapEffect | System.Windows.Media.Effects.BitmapEffect BitmapEffect {get;set;} |
| BitmapEffectInput | System.Windows.Media.Effects.BitmapEffectInput BitmapEffectInput {get;set;} |
| BreakAfter | System.Windows.LineBreakCondition BreakAfter {get;} |
| BreakBefore | System.Windows.LineBreakCondition BreakBefore {get;} |
| Clip | System.Windows.Media.Geometry Clip {get;set;} |
| ClipToBounds | System.Boolean ClipToBounds {get;set;} |
| CommandBindings | System.Windows.Input.CommandBindingCollection CommandBindings {get;} |
| ContentEnd | System.Windows.Documents.TextPointer ContentEnd {get;} |
| ContentStart | System.Windows.Documents.TextPointer ContentStart {get;} |
| ContextMenu | System.Windows.Controls.ContextMenu ContextMenu {get;set;} |
| Cursor | System.Windows.Input.Cursor Cursor {get;set;} |
| DataContext | System.Object DataContext {get;set;} |
| DependencyObjectType | System.Windows.DependencyObjectType DependencyObjectType {get;} |
| DesiredSize | System.Windows.Size DesiredSize {get;} |
| Dispatcher | System.Windows.Threading.Dispatcher Dispatcher {get;} |
| Effect | System.Windows.Media.Effects.Effect Effect {get;set;} |
| FlowDirection | System.Windows.FlowDirection FlowDirection {get;set;} |
| Focusable | System.Boolean Focusable {get;set;} |
| FocusVisualStyle | System.Windows.Style FocusVisualStyle {get;set;} |
| FontFamily | System.Windows.Media.FontFamily FontFamily {get;set;} |
| FontSize | System.Double FontSize {get;set;} |
| FontStretch | System.Windows.FontStretch FontStretch {get;set;} |
| FontStyle | System.Windows.FontStyle FontStyle {get;set;} |
| FontWeight | System.Windows.FontWeight FontWeight {get;set;} |
| ForceCursor | System.Boolean ForceCursor {get;set;} |
| Foreground | System.Windows.Media.Brush Foreground {get;set;} |
| HasAnimatedProperties | System.Boolean HasAnimatedProperties {get;} |
| Height | System.Double Height {get;set;} |
| HorizontalAlignment | System.Windows.HorizontalAlignment HorizontalAlignment {get;set;} |
| Inlines | System.Windows.Documents.InlineCollection Inlines {get;} |
| InputBindings | System.Windows.Input.InputBindingCollection InputBindings {get;} |
| InputScope | System.Windows.Input.InputScope InputScope {get;set;} |
| IsArrangeValid | System.Boolean IsArrangeValid {get;} |
| IsEnabled | System.Boolean IsEnabled {get;set;} |
| IsFocused | System.Boolean IsFocused {get;} |
| IsHitTestVisible | System.Boolean IsHitTestVisible {get;set;} |
| IsHyphenationEnabled | System.Boolean IsHyphenationEnabled {get;set;} |
| IsInitialized | System.Boolean IsInitialized {get;} |
| IsInputMethodEnabled | System.Boolean IsInputMethodEnabled {get;} |
| IsKeyboardFocused | System.Boolean IsKeyboardFocused {get;} |
| IsKeyboardFocusWithin | System.Boolean IsKeyboardFocusWithin {get;} |
| IsLoaded | System.Boolean IsLoaded {get;} |
| IsMeasureValid | System.Boolean IsMeasureValid {get;} |
| IsMouseCaptured | System.Boolean IsMouseCaptured {get;} |
| IsMouseCaptureWithin | System.Boolean IsMouseCaptureWithin {get;} |
| IsMouseDirectlyOver | System.Boolean IsMouseDirectlyOver {get;} |
| IsMouseOver | System.Boolean IsMouseOver {get;} |
| IsSealed | System.Boolean IsSealed {get;} |
| IsStylusCaptured | System.Boolean IsStylusCaptured {get;} |
| IsStylusCaptureWithin | System.Boolean IsStylusCaptureWithin {get;} |
| IsStylusDirectlyOver | System.Boolean IsStylusDirectlyOver {get;} |
| IsStylusOver | System.Boolean IsStylusOver {get;} |
| IsVisible | System.Boolean IsVisible {get;} |
| Language | System.Windows.Markup.XmlLanguage Language {get;set;} |
| LayoutTransform | System.Windows.Media.Transform LayoutTransform {get;set;} |
| LineHeight | System.Double LineHeight {get;set;} |
| LineStackingStrategy | System.Windows.LineStackingStrategy LineStackingStrategy {get;set;} |
| Margin | System.Windows.Thickness Margin {get;set;} |
| MaxHeight | System.Double MaxHeight {get;set;} |
| MaxWidth | System.Double MaxWidth {get;set;} |
| MinHeight | System.Double MinHeight {get;set;} |
| MinWidth | System.Double MinWidth {get;set;} |
| Name | System.String Name {get;set;} |
| Opacity | System.Double Opacity {get;set;} |
| OpacityMask | System.Windows.Media.Brush OpacityMask {get;set;} |
| OverridesDefaultStyle | System.Boolean OverridesDefaultStyle {get;set;} |
| Padding | System.Windows.Thickness Padding {get;set;} |
| Parent | System.Windows.DependencyObject Parent {get;} |
| PersistId | System.Int32 PersistId {get;} |
| RenderSize | System.Windows.Size RenderSize {get;set;} |
| RenderTransform | System.Windows.Media.Transform RenderTransform {get;set;} |
| RenderTransformOrigin | System.Windows.Point RenderTransformOrigin {get;set;} |
| Resources | System.Windows.ResourceDictionary Resources {get;set;} |
| SnapsToDevicePixels | System.Boolean SnapsToDevicePixels {get;set;} |
| Style | System.Windows.Style Style {get;set;} |
| Tag | System.Object Tag {get;set;} |
| TemplatedParent | System.Windows.DependencyObject TemplatedParent {get;} |
| Text | System.String Text {get;set;} |
| TextAlignment | System.Windows.TextAlignment TextAlignment {get;set;} |
| TextDecorations | System.Windows.TextDecorationCollection TextDecorations {get;set;} |
| TextEffects | System.Windows.Media.TextEffectCollection TextEffects {get;set;} |
| TextTrimming | System.Windows.TextTrimming TextTrimming {get;set;} |
| TextWrapping | System.Windows.TextWrapping TextWrapping {get;set;} |
| ToolTip | System.Object ToolTip {get;set;} |
| Triggers | System.Windows.TriggerCollection Triggers {get;} |
| Typography | System.Windows.Documents.Typography Typography {get;} |
| Uid | System.String Uid {get;set;} |
| VerticalAlignment | System.Windows.VerticalAlignment VerticalAlignment {get;set;} |
| Visibility | System.Windows.Visibility Visibility {get;set;} |
| Width | System.Double Width {get;set;} |
参考文献:TextBlock クラス (System.Windows.Controls)
http://msdn.microsoft.com/ja-jp/library/system.windows.controls.textblock(VS.80).aspx




コメント