1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Visual Studio / WPF > コントロール > レイアウト > Widthの指定の仕方 > 100 | 3in | 10cm | 50pt | Auto | 比率指定:"2*"

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

@ WPF 4.5入門 by 大田一希さん
No.2764 / 9985

WidthやHeightなどでの値の指定の仕方を色々紹介されている。

Buttonで試してみた。

XAML
<Window x:Class="_170425_t0714_width_various.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:_170425_t0714_width_various"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <StackPanel>
            <Button Width="100" Content="Button100"/>
            <Button Width="3in" Content="Button3in"/>
            <Button Width="10cm" Content="Button10cm"/>
            <Button Width="50pt" Content="Button50pt"/>
            <Button Width="Auto" Content="ButtonAuto"/>
        </StackPanel>
    </Grid>
</Window>
```


![work.png](https://qiita-image-store.s3.amazonaws.com/0/32870/4cc6b6f9-4a77-407f-73a0-b02da1c56ad8.png)

@ WPF 4.5入門 by 大田一希さん
No.2891 / 9985
> WPFでのピクセルは、物理的なピクセルではなくデバイス非依存ピクセルになりmす。デバイス非依存ピクセルとは、dpi(1インチあたりのドット数)にかかわらず1ピクセルが1/96インチになります。

<hr>
(追記 2017/06/14)

http://www.atmarkit.co.jp/ait/articles/1011/30/news116_2.html
に比率指定 `Width="2*"`が紹介されている。


1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?