LoginSignup
0
1

More than 5 years have passed since last update.

Visual Studio / WPF > 11 StackPanel布局 > Button内にImageとTextBlockを配置するためにStackPanelを使用

Last updated at Posted at 2017-05-11
動作環境
Windows 7 Pro (32bit)
Microsoft Visual Studio 2017 Community
Sublime Text 2

11 StackPanel布局
https://www.youtube.com/watch?v=bFbqKxbLDSA&list=WL&index=31

Button.Cotent内にImageとTextBlockを配置する例にてStackPanelを使う方法を紹介している。

試してみた。

手順

work.pngという画像を用意して、プロジェクトに追加しておく。
Visual Studio / WPF > コントロール > Image > 画像が見えない > Resourceとしてファイルを追加する / Ctrl+vでファイルを追加する

以下のようにXAMLを用意する。

MainWindow.xaml
<Window x:Class="_170512_t0624_stackPanel.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:_170512_t0624_stackPanel"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Button HorizontalAlignment="Left" Margin="52,51,0,0" VerticalAlignment="Top" Width="424" Height="199">
            <Button.Content>
                <StackPanel>
                    <TextBlock>You press the button,</TextBlock>
                    <Image Source="work.png" Height="100"></Image>
                    <TextBlock>we do the rest</TextBlock>
                </StackPanel>
            </Button.Content>
        </Button>

    </Grid>
</Window>

work.png

You press the button, we do the restというフレーズはこちらから借用

中国語 > 布局

bùjú
http://cjjc.weblio.jp/content/%E5%B8%83%E5%B1%80

(都市・工業などの)構成,配置,レイアウト.

中国語 > "."

"."のことをdianと言っているのかもしれない。
Button.Content (ボタン dian Content)

句点(。),ピリオド(.).⇒标点符号 biāodiǎn fúhào .

(追記 2018/10/19)

点: Diǎnと同じなのだろう。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1