Architect's Log

I'm a Cloud Architect. I'm highly motivated to reduce toils with driving DevOps.

Canvasにレイアウトする

アプリ実行


4つ全て指定すると、TopとLeftが優先されるようですね。

ソースコード

App.xaml
<Application x:Class="HelloWorld.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
</Application>
MainWindow.xaml
<Window x:Class="WpfApplication4.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Canvas Width="200" Height="100" Background="Aqua">
        <TextBlock Canvas.Right="2" Canvas.Top="2">Top, Right</TextBlock>
        <TextBlock Canvas.Left="2" Canvas.Top="2">Top, Left</TextBlock>
        <TextBlock Canvas.Right="2" Canvas.Bottom="2">Bottom, Right</TextBlock>
        <TextBlock Canvas.Left="2" Canvas.Bottom="2">Bottom, Left</TextBlock>
        <TextBlock Canvas.Left="20" Canvas.Bottom="20" Canvas.Right="20" Canvas.Top="20">4つすべて</TextBlock>
    </Canvas>
</Window>