Architect's Log

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

コントロールで塗りつぶす

App.xaml

<Application
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    StartupUri="MainWindow.xaml"
/>

MainWindow.xaml

<Window
    x:Class="HelloWorld.MainWindow"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    Title="Hello World"
    >
    <StackPanel>
        <Button Width="100" Height="20" x:Name="button">テスト</Button>
        <Rectangle Width="500" Height="300">
            <Rectangle.Fill>
                <!-- Viewportで横2つ、縦4つに指定する -->
                <VisualBrush
                    Visual="{Binding ElementName=button}"
                    Viewport="0, 0, 0.5, 0.25"
                    TileMode="Tile" />
            </Rectangle.Fill>
        </Rectangle>
    </StackPanel>
</Window>

アプリ実行