ComboBox 等に使われている▼を描画する

はじめに

ComboBox や NumericUpDown で表示されている▼マークを描画してみました。

XAML を記述

<UserControl x:Class="PathSample.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="150" Height="150">
    <Grid x:Name="LayoutRoot" Background="White">
        <Path Width="8" Height="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Stretch="Uniform" Margin="0,0,0,0" Data="F1 M 531.107,321.943L 541.537,321.943L 536.322,328.042L 531.107,321.943 Z ">
            <Path.Fill>
                <SolidColorBrush Color="#FF333333"/>
            </Path.Fill>
        </Path>
    </Grid>
</UserControl>

実行画面

f:id:griefworker:20081226153004p:image

まとめ

Path を使えば一発ですね。

最後に

今回は小ネタもいいところです。でも、もしかしたら需要があるかも…。Button のテキスト代わりに使ったり、Image と重ねて Firefox の検索ボックスみたいなコントロールを作ったりする時に。